Add sitemap GraphQL query #88
Replies: 12 comments 4 replies
-
I'm not sure how the sitemap based on your Statamic routes is relevant in a headless setup, as routing is taken care of by the frontend framework. How is Advanced SEO supposed to know about your frontend routing? In React or Vue land you would use a package that generates the sitemap based on your frontend routes. Also, what do you mean by |
Beta Was this translation helpful? Give feedback.
-
I think more often than not frontend routing somehow relies on the data structure in the backend. In my case I have a nested collection query Page($uri: String!) {
entry(uri: $uri) {
id
}
} I could of course make a couple of queries and merge date I get from I'm no expert in React or Vue land, but here is a a link to the NuxtSeo Docs, talking about generating a Sitemap for dynamic URLs https://nuxtseo.com/sitemap/guides/dynamic-urls, which basically involves returning an array of locations with fields With flat XML sitemap I'm referring to just one XML document |
Beta Was this translation helpful? Give feedback.
-
For the sitemap to be useful, your frontend routes have to be perfectly synced with Statamic's routes. Is that realistic? Imagine you've got one additional route that isn't taken care of by Statamic. Now you've got an incomplete sitemap. Of course, that's only the case with a rendered XML. If you could query the sitemap data, you could still add and remove items and take care of the XML yourself. I think this could make sense. As for the flat sitemap, why would you need this? |
Beta Was this translation helpful? Give feedback.
-
Having frontend-routes in sync with backend routes is definitely the case for me. I also have a strong incentive here, as by using your addon I'm enabling my client to control seo meta data on every page, through some collection entry. Admittedly mine might be a special use-case and I would be also very glad if instead of an sitemap |
Beta Was this translation helpful? Give feedback.
-
I'm adding this to my list of feature requests. I won't implement the "flat" sitemap, though. Separating sitemaps was an architectural decision to improve performance. And nested sitemaps work fine. I don't see a reason why you'd need a flat sitemap. |
Beta Was this translation helpful? Give feedback.
-
@aerni Great, thank you! much appreciated ... |
Beta Was this translation helpful? Give feedback.
-
When we create (headless) websites, Statamic is our source of truth and collections urls are configured from Statamic. Custom (FE-only) pages can be added manually by the frontend module. For example we use Nuxt and Nuxt simple sitemap which supports dynamic URL's. (https://nuxtseo.com/sitemap/guides/dynamic-urls) For us it doesn't matter if the sitemap is 'flat' or not, important is that we can do whatever what we want with it. |
Beta Was this translation helpful? Give feedback.
-
I've got a first implementation going. How does the following look to you? Any additional arguments or filters that would make sense on the query? query MyQuery {
seoSitemap {
alternates {
href
hreflang
}
changefreq
lastmod
loc
priority
}
} {
"data": {
"seoSitemap": [
{
"alternates": [
{
"href": "https://statamic-advanced-seo.test/about",
"hreflang": "en-US"
},
{
"href": "https://statamic-advanced-seo.test/german/about",
"hreflang": "de-DE"
}
],
"changefreq": "daily",
"lastmod": "2023-05-15T20:05:17+00:00",
"loc": "https://statamic-advanced-seo.test/german/about",
"priority": "0.5"
},
{
"alternates": [
{
"href": "https://statamic-advanced-seo.test/about",
"hreflang": "en-US"
},
{
"href": "https://statamic-advanced-seo.test/german/about",
"hreflang": "de-DE"
}
],
"changefreq": "daily",
"lastmod": "2023-05-15T20:19:38+00:00",
"loc": "https://statamic-advanced-seo.test/about",
"priority": "0.5"
},
{
"alternates": [],
"changefreq": "daily",
"lastmod": "2023-05-16T13:05:10+00:00",
"loc": "https://statamic-advanced-seo.test",
"priority": "0.5"
},
{
"alternates": [],
"changefreq": "daily",
"lastmod": "2023-07-28T13:46:09+00:00",
"loc": "https://statamic-advanced-seo.test/tags",
"priority": "0.5"
}
]
}
} |
Beta Was this translation helpful? Give feedback.
-
Looking good to me! |
Beta Was this translation helpful? Give feedback.
-
Wouldn't you need a |
Beta Was this translation helpful? Give feedback.
-
Any other query arguments that could be useful? Like only querying sitemap items of a certain collection. Or filters to only get items with a certain priority? Just brainstorming here before finalizing the implementation. |
Beta Was this translation helpful? Give feedback.
-
Could you give PR #96 a try before I tag a release? |
Beta Was this translation helpful? Give feedback.
-
It would be nice if a flat XML sitemap could be queried through GraphQL
Beta Was this translation helpful? Give feedback.
All reactions