IDEA: Sitemap support?
heychazza opened this issue · 8 comments
Thanks for building this! Could you add a sitemap generation with this if possible?
I believe that could be possible with a server route calling fetchContentNavigation()
and generating a XML.
Something like server/routes/sitemap.xml.ts
, do you mind trying?
You can import fetchContentNavigation
from #content/server
Then we can add the /sitemap.xml
route to nitro.prerender
in nuxt.config.ts
I believe that could be possible with a server route calling
fetchContentNavigation()
and generating a XML.Something like
server/routes/sitemap.xml.ts
, do you mind trying?You can import
fetchContentNavigation
from#content/server
Then we can add the
/sitemap.xml
route tonitro.prerender
innuxt.config.ts
Thanks for your reply! Just tried:
Package import specifier "#content" is not defined
With:
import {fetchContentNavigation, queryContent} from "#content/server";
export default defineEventHandler((event) => {
const query = queryContent('blog')
const blogs = fetchContentNavigation(query)
return {
api: blogs
}
})
Can you share a StackBlitz or open a PR to play with it?
Can you share a StackBlitz or open a PR to play with it?
Hey buddy, https://stackblitz.com/edit/github-d1ngrx-ss7vne?file=nuxt.config.ts
I updated your Stackblitz, it was missing @nuxt/content
dependency and it was not activated either.
See a working example: https://stackblitz.com/edit/github-d1ngrx-3vu7ua?file=server%2Froutes%2Fsitemap.xml.ts
https://stackblitz.com/edit/github-d1ngrx-3vu7ua?file=server%2Froutes%2Fsitemap.xml.ts
Ah so we need serverQueryContent
in this case?
How would we query for remaining pages too? Like ones not from nuxt content? Happy to make a PR once I can get all the pages and generate a full sitemap.
For remaining pages you will have to add them manually.
I think this example can be documented in Nuxt Content directly about how to create a sitemap based on the content files.
Personally I never generated sitemap and always had great SEO.
For remaining pages you will have to add them manually.
I think this example can be documented in Nuxt Content directly about how to create a sitemap based on the content files.
Personally I never generated sitemap and always had great SEO.
Oh wow really? I wasn't sure if sitemaps were needed, I'm happy to P.R the entire sitemap generation (using a sitemap lib) to Nuxt Content.