First, to demonstrate what I mean, I've set up a demo Nuxt blog at https://debadeepsen.com/nuxtblog/. It has the articles populated by the @nuxt/content package. The deployed website has been generated via the nuxt generate command and as such, is fully static. Now perform the following actions -
The steps taken above lead to results that are expected. But now, reload any of the article pages. You will notice the following -
Obviously, these pages don't exist, and therefore the links are now broken.
My code is pretty straightforward. Here's the navigation menu -
<ul>
<li v-for="article in list" :key="article.slug">
<nuxt-link :to="article.slug">
{{ article.title }}
</nuxt-link>
</li>
</ul>
The state variable
listhas correct data in it, no problem there.
In my nuxt.config.js, I have -
export default {
// ...
router: {
base: '/nuxtblog/'
},
// ...
}
So, what am I doing wrong here and how can I fix this problem?
Either use named routes in your to property or start the path with a leading /.