content: Nuxt 3 Static Site Generation does not generate anything for content
Environment
------------------------------
- Operating System: `Darwin`
- Node Version: `v19.1.0`
- Nuxt Version: `3.1.1`
- Nitro Version: `2.1.0`
- Package Manager: `npm@8.19.3`
- Builder: `vite`
- User Config: `routeRules`, `ssr`, `postcss`, `app`, `modules`, `content`, `runtimeConfig`
- Runtime Modules: `@nuxt/content@2.4.3`
- Build Modules: `-`
------------------------------
Reproduction
Create a nuxt 3 project and add a /content directory
Add any .md to the /content directory
Run npx nuxi generate
Instead of static content actually being generated, an /api/_content/<query or navigation>/<somestring>.json file is created.
This means that the statement You can now deploy .output/public to any static hosting! is false; you cannot simply upload the contents of .output/public and expect it to work; you need a server with routing back to the main index.html.
This negates any SEO benefit for using the /content with Nuxt 3
Describe the bug
As stated, using generate does not generate any static content from the /content directory, negating any SEO benefit. Ideally, anything in .output/public could be uploaded to, say, S3 with static website hosting enabled, and it would work.
The fact it outputs JSON files and expects all requests to route back to the main index.html file means that:
- The content is not static, it needs to fetch data asynchronously from the server, even if that data is static JSON
- Any SEO benefit that existed in Nuxt 2 using
generateno longer exists in Nuxt 3.
Is there something I’m missing? This should be working if we’re calling this “stable”, no?
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 9
- Comments: 19 (10 by maintainers)
NOTE: A workaround for this is to manually define every route in
nuxt.config.ts, like:To be honest, this is tedious; the only way to get around this is to write something that crawls the content in the
/contentdirectory and adds it to this config. Which…why doesn’t nuxt 3 just do it outright?I cannot get Nuxt to generate my markdown files. Frustrating because my old blog on Nuxt 2 worked way more easily.
When Nitro crawls your website, it does the same job that is done by a Google Bot (https://developers.google.com/search/docs/crawling-indexing/googlebot).
You can take a look at Docus, https://github.com/nuxt-themes/docus or Alpine, https://github.com/nuxt-themes/alpine, to understand how things works.
I think there is a miss understanding of how nuxt/content works.
/contentis like a database where you can store Markdown, JSON, CSV and more. Alone, they do nothing and they do not represent a page. But nuxt/content gives us a tool to query this database calledqueryContent.Nitro, on its side, will start at
/(from your server so<ip>:<port>/) and crawls into your site using anchor tags. So Nitro is not aware of the/contentfolder (which is like database).Knowing this, we understand that you have 3 solutions:
/to crawling by NitroWe actually generate our docs with Content and it works perfectly.
Happy to help but we will need a reproduction, cannot guess without looking at the code