Markdown files not found in production
See original GitHub issue“@nuxt/content”: “^1.14.0”, “nuxt”: “^2.15.3”
I don’t want to bother you if I can but for whatever reason the articles are just not being generated in production. I have been following this article.
My folder structure:
content/category/my-first-blog-post.md
My config:
target: 'static',
// pages/en/_slug.vue
async asyncData({ $content, params, error }) {
let article
try {
article = await $content('category', params.slug).fetch()
} catch (err) {
error({
statusCode: 404,
message: err
})
}
return { article }
}
On my local http://localhost:3000/en/my-first-blog-post
it works fine, but in production after deploying to Netlify, Netlify will return 404
. Making a get
request to /_content
does not work as well and will return 404
. I have also ran nuxt generate
and nuxt start
to test out the site before deploying and it works perfectly.
I can’t figure out why its failing in Netlify, I’ve cleared cache and redeployed multiple times but the result is the same. It can only load the home page ‘/’ but not any other page. Link to the article on my site on Netlify.
Update: I’ve downloaded the dist/
directory generated by Netlify and compare it with my local dist/
and its pretty much the same. I’m starting to suspect its a Netlify thing?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
I stand corrected and @ManasMadrecha is correct. For anyone else who visits this, you need to fetch the articles in an index page first before being able to navigate to the article.
@romain130492 We need to display the list of all posts somewhere in the whole website. It’s your choice where you display it, either in the
/content
folder’s md files or in the/pages
folder’s vue files.If you choose to write the links in md files, then they will be generated automatically because Nuxt can crawl it. But since you may not know which all links you have to type manually, it’s better to display the links in
/pages
vue file by fetching all the posts in it and displaying it in template.But, if you do know that you only need to generate, say x no. of posts, then you can type them inside any md file, as long as that md file has also its link written somewhere in other md file or other vue file.