Contentful logo

Contentful Community

Content preview linkedBy not working

I’m trying to set up a content preview using a linked field. My preview url is as follows:

https://my-preview-env.com/{entry.linkedBy.fields.url}

but what that gives me when I click on the preview button is:

https://my-preview-env.com/linkedBy.fields.url_%20NOT_FOUND

I’m guessing that the issue is that my entry is linked to by many other entries, and the one containing the url is not the first in the response. Is there any way to change the order of the response here, or any way to specify the entry to pull the url field from?

Hi Daniel,

As you can check out in the documentation in the content preview setup page itself, the syntax for using incoming links would be as follows:

{entry.linkedBy.linkedBy.fields.slug} : value of the slug field for the entry, which references another entry

Hi gabriel,

Thanks, but this still doesn’t work for me. When I first read the guide I thought that the syntax you’ve given was for accessing a field on an entry two levels up from the current one (so for entry containing slug -> intermediate entry -> current_entry entry.linkedBy would access the intermediate entry, and entry.linkedBy.linkedBy would access the entry containing the slug), is that the case?

In my case the entry containing the url field directly references the page I’m trying to preview, but I can’t access the field in the preview.

@daniel.whyte can you share screenshots of your content preview setup? Cause I just tried this and it works just fine for me.

I have a Nav content type which has

  • a name short text field,
  • a slug short text field, and
  • a content reference field which can reference entries of the content type Page.

The Page content type then has

  • a Name short text field and
  • a Body rich text field.

I have content preview set up on the Page content type with the url like this: https://www.example.com/{entry.linkedBy.fields.slug}/

I’ve made a Nav entry with a slug of about-us and that references a Page entry and on that page entry when I click on the Open preview button, it takes me to https://www.example.com/about-us/.

Does that all make sense? How is your config/setup different?

Hi @charlie,

The example you’ve given is almost exactly how I have my model set up, and in that particular case everything works perfectly fine.

My problem arises when I have a third content type, HubPage, which has

  • a name short text field
  • a childPages reference field, which can reference many Pages

In this case, if I have both a HubPage and a Nav linking to my Page, the {entry.linkedBy.fields.slug} will sometimes not work, instead returning fields.slug_%20NOT_FOUND, presumably because it’s looking for the slug field on the HubPage rather than the Nav.

I think the problem is only caused when the HubPage is the first item in the Links list

For example, in the first sidebar here, the Nav is the first item, and the link works, taking me to https://www.example.com/page-1/

In the second sidebar, the HubPage is the first item, and the link does not work, taking me to https://www.example.com/linkedBy.fields.slug_%20NOT_FOUND/: