Malformed Content Preview URLs

Hello! I’m trying to set up a content preview for my space, but having trouble getting Contentful to register the {entry.fields.slug} token in my URL templates. This is the URL template I’ve provided for my “Campaign” content type:

https://phoenix-preview.dosomething.org/us/campaigns/{entry.fields.slug}

When I click the “Open preview” button on this content type, I end up at the following URL:

https://phoenix-preview.dosomething.org/us/campaigns/fields.slug_%20NOT_FOUND

Surprisingly, this does work as expected for my content type that uses a slug on a linked entry of the exact same content type:

https://phoenix-preview.dosomething.org/us/campaigns/{entry.linkedBy.fields.slug}/blocks/{entry.sys.id}
https://phoenix-preview.dosomething.org/us/campaigns/grab-mic/blocks/2Sfb7g0pSgeuIqU6moOOAY

Is this a bug? Am I doing something wrong? Thanks in advance for any help!

2 Likes

does your Campaign content type have a slug field? Or is there a content type which has a slug field and a reference field to the Campaign content type?

Imagine you have a page content type that has a slug field as well as a component content type. You could set up content preview for components with entry.linkedBy.fields.slug which accesses the slug on the first page which links to the component being edited.

check out our knowledge base article about content preview: https://www.contentful.com/r/knowledgebase/setup-content-preview/

Hi Charlie! Thanks for the response.

Our Campaign content type does have a slug field. In my second example, that’s the field that’s being resolved by {entry.linkedBy.fields.slug}. That’s why I’m surprised that it works as expected in one scenario, but not when directly asking for {entry.fields.slug} on the Campaign itself.

I see your linked article suggests using {entry_field} instead of {entry.fields} like the “help sidebar” in the app instructs. I still get the same “fields.slug_%20NOT_FOUND” URL when I try it, but should I prefer using that instead?

Here’s my content model for the Campaign type. The highlighted “Slug” field has a machine name of slug.

In my second example above, it seems like this field resolves fine when using {entry.linkedBy.fields.slug} (where entry.linkedBy is a campaign resource) so I’m surprised it doesn’t on the campaign itself!

Did you try “Slug” instead of “slug” ?

Hi @dfurnes,
Following up on this, it appears this was related to a small issue in our Web Interface and our team is already investigating what could be behind this.

I’ll let you all know of any updates on this. :slight_smile: