I'm running a query in Contentful delivery API to return a particular page item based in it's slug. This query is also setting the locale so that it will only return the data in the language I need to render.
However, I also will need to set the hreflang tags of the page to help google know that this page is also available in other languages.
The response I get from contentful for this contentful item that represents my page doesn't seem to have any kind of array property that let's me easily determine what other languages the content is available in.
I'm assuming this must be a pretty common requirement for SEO, so hoping someone can indicate to me how I can get this in the response from Contentful?
Here's an example of my response. What I would have hoped to see was say another property called allLocales
that would have a list of every locale that this content could be served with.
Update:
I know I can get a list of all locales in the Space, as well as set locales=*
in my query, but this still doesn't help. I need to know only the subset of locales that are available on a given piece of content that I have retrieved. For example, one page might only support 2 locales, but there might be 3 or more locales available in the entire space.
Locales=* does not help because it includes locales on every link item (which may or may not have content), and what I need is one single array object that contains all the locales that could be available on the parent content item. Even if a user does not put content in a field, I want to know categorically whether the locale has been selected on the content.
{
"sys": {
"type": "Array"
},
"total": 1,
"skip": 0,
"limit": 1,
"items": [
{
"sys": {
"space": {
"sys": {
"type": "Link",
"linkType": "Space",
"id": "xuehyxrgb9ri"
}
},
"id": "1MhAzkNYvOSU8GgUQcQKqa",
"type": "Entry",
"createdAt": "2018-01-05T10:48:30.373Z",
"updatedAt": "2018-01-05T12:57:00.066Z",
"revision": 6,
"contentType": {
"sys": {
"type": "Link",
"linkType": "ContentType",
"id": "contentPage"
}
},
"locale": "en-AU"
},
"fields": {
"title": "Test Page",
"slug": "test-page",
"content": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "Vt4ktGvOE0qoO8mqeCMao"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "2jY5LUgHWUsaIyMuwKwYe2"
}
}
]
}
}
]
}