Link to document from another locale

Hi there,

for our SEO purposes we want to set e.g. the <link rel="alternate" hrefLang="en" href=<URL> /> tag in our head.

However, since our link structure is different and one page can have different routes in our locales, it would be nice to set a document relationship in our prismic where we could link to a document from a different route, so we could get the meta information there.

Is that somehow possible?

1 Like

Hey Andi, thank you for reaching out!

It sounds like you're describing the Content Relationship field:

This field allows you to link to another document in your Prismic repository. And of course, once you query the document in your project you can access the alternate languages, in the meta data of the document to find it's translations.

It'll depend on which technology you're using to query, but this is how you'd retrieve meta data information in GraphQL:

1 Like

Hi Paulina,

thanks for getting back!

I'm using the Prismic Predicates API to query my data - so basically the JS API. For SEO purposes I already created a canonical field which is basically a content relationship field linking to the same document it's placed in.

So with the Predicates API, how would you achieve this? This information should live inside the _meta field or should I fire a fetchLinks action within the query?

The thing is - if I copy a document to another locale and change the uid of the copied document - are they still linked to the "original" document?

Thx!

Found the fix - once querying a page/document with the JS api, we receive a alternate_languages array from the API and this is exactly the data I was looking for :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.