[Vuejs]-"Invalid URL" error for markdown file using Nuxt content module

0👍

Using this configuration in nuxt.config.js, I was able to generate the sitemap for my Nuxt site using the content module:

sitemap: {
    hostname: 'https://my-website-url.com',
    gzip: true,
    routes: async () => {
      let routes = []
      const { $content } = require('@nuxt/content')
      let posts = await $content('posts').fetch()
      for (const post of posts) {
        routes.push(`blog/${post.slug}`)
      }
      return routes
    },
  },

I tested this both with a local build as well as deploying to Netlify.

One configuration I see that could be different is that the route you are returning may not be a valid endpoint. The return for the routes should be an array of valid relative URLs. Are you hosting your blog posts as "https://url.com/{post}"?

The above code is based on the Nuxt Content integrations page.

Leave a comment