nuxt-modules / sitemap Goto Github PK
View Code? Open in Web Editor NEWPowerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
Home Page: https://nuxtseo.com/sitemap
Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
Home Page: https://nuxtseo.com/sitemap
i'm getting the following error after i install this module
- Operating System: `Darwin`
- Node Version: `v16.18.1`
- Nuxt Version: `3.5.1`
- Nitro Version: `2.4.1`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `app`, `nitro`, `routeRules`, `modules`, `intlify`, `css`, `image`, `runtimeConfig`
- Runtime Modules: `@nuxtjs/[email protected]`, `@pinia/[email protected]`, `@pinia-plugin-persistedstate/[email protected]`, `@vueuse/[email protected]`, `@formkit/[email protected]`, `@intlify/[email protected]`, `[email protected]`
- Build Modules: `-`
For websites that are hosted in a subdirectory, for example https://example.com/subdirectory/{files}
I configure Nuxt's baseURL and Nitro's publicDir to output the site files in the subdirectory required.
The sitemap.xml that is generated includes URL's without the subdirectory:
The last two URL's in my screenshot which include the subdirectory path are created by adding <NuxtLink>
's that point to the pages.
I think the first two URL's must be generated based on the page directory or something similar, which don't account for the subdirectory.
In the reproduction:
npm run generate
code .output/public/subdirectory/sitemap.xml
to view the sitemap file.https://stackblitz.com/edit/nuxt-starter-r74ewa
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 2.01 GB / 15.85 GB
Binaries:
Node: 18.12.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 110.0.5481.177
Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.57)
Internet Explorer: 11.0.19041.1566
npm
The dynamic urls are not generated from [email protected] to [email protected]
I tried every versions of the packages, it only works in [email protected] (didn't tried below).
No response
- Operating System: Darwin
- Node Version: v19.7.0
- Nuxt Version: 3.4.2
- Nitro Version: 2.3.3
- Package Manager: [email protected]
- Builder: vite
- User Config: typescript, modules, generateSvgsViewboxes, i18n, svgo, image, robots, sitemap, feed, runtimeConfig, vue, vite, nitro, routeRules, css, app
- Runtime Modules: ~~/modules/download-global/index.ts, ~~/modules/download-routes-params/index.ts, ~~/modules/cms-redirections/index.ts, ~~/modules/generate-svgs-viewboxes/index.ts, ~~/modules/lite-youtube-embed/index.ts, ~~/modules/feed/index.ts, @nuxtjs/[email protected], [email protected], @nuxt/[email protected], [email protected], [email protected]
- Build Modules: -
Hi,
Am I doing something wrong after updating to v2 because I can't view the XML.
Only this empty HTML site: https://nuxt3-vercel-mu.vercel.app/sitemap.xml
// nuxt.config.ts
sitemap: {
siteUrl: 'https://' + process.env.VERCEL_URL
},
No response
No response
Attribute in sitemap.xml contains hreflang="[object Object]"
instead of language code.
The same problem with links but sitemap also contains unnecessary lang subdirectory for lang route.
<url>
<loc>https://some-host-name</loc>
<lastmod>2023-04-05T22:59:06+00:00</lastmod>
<xhtml:link rel="alternate" hreflang="[object Object]" href="https://some-host-name/%5Bobject%20Object%5D" />
<xhtml:link rel="alternate" hreflang="[object Object]" href="https://some-host-name/%5Bobject%20Object%5D" />
</url>
<url>
<loc>https://some-host-name/en</loc>
<xhtml:link rel="alternate" hreflang="[object Object]" href="https://some-host-name/%5Bobject%20Object%5D/en" />
<xhtml:link rel="alternate" hreflang="[object Object]" href="https://some-host-name/%5Bobject%20Object%5D/en" />
</url>
https://stackblitz.com/edit/nuxt-starter-izjkhm
"nuxt": "^3.3.3",
"@nuxtjs/i18n": "^8.0.0-beta.8",
"nuxt-simple-sitemap": "^2.4.3"
Binaries:
Node: 18.12.1
npm: 9.1.2.
I have a directory structure
pages
/blog.vue
/blog
/categories.vue
/tags.vue
/index.vue
pages/blog.vue has a <NuxtPage />
which allows it serve as a root to the categories and tags.
But, the sitemap plugin doesn't scan through the child pages.
in code, it generates
{ 17:45:23
name: 'blog',
path: '/blog',
file: '[path-to-app]/pages/blog.vue',
children: [
{
name: 'blog-categories',
path: '/blog/categories',
file: '[path-to-app]/pages/blog/categories.vue',
children: []
},
{
name: 'blog-tags',
path: '/blog/tags',
file: '[path-to-app]/pages/blog/tags.vue',
children: []
},
{
name: 'blog',
path: '/blog/',
file: '[path-to-app]/pages/blog/index.vue',
children: []
}
]
}
the children never gets generated.
https://stackblitz.com/edit/nuxt-starter-sxgico?file=app.vue
------------------------------
- Operating System: `Linux`
- Node Version: `v16.14.2`
- Nuxt Version: `3.3.2`
- Nitro Version: `2.3.2`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `modules`, `sitemap`
- Runtime Modules: `[email protected]`
- Build Modules: `-`
------------------------------
After updating to v2.0.2 and running nuxt build
this happens (while building Nitro server):
RollupError: Could not resolve "../../page-utils" from "node_modules/nuxt-simple-sitemap/dist/runtime/util/entries.mjs"
No response
Nuxt: v3.1.3
Nitro: v2.3.1
Sitemap: v2.0.2
Hi !
Thanks for making this module !
I am contacting you because I have been unable to get through the build since upgrading to v2.
With v1, the build passes normally.
run with
$ nuxi generate
v2.1.7
v1.0.9
No response
------------------------------
- Operating System: `Darwin`
- Node Version: `v16.16.0`
- Nuxt Version: `3.3.1`
- Nitro Version: `2.3.1`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `app`, `typescript`, `nitro`, `modules`, `googleFonts`, `sitemap`, `vite`, `css`, `build`
- Runtime Modules: `@nuxt/[email protected]`, `@nuxtjs/[email protected]`, `@nuxtjs/[email protected]`, `[email protected]`
- Build Modules: `-`
------------------------------
👉 Report an issue: https://github.com/nuxt/nuxt/issues/new 04:01:54
👉 Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new
👉 Read documentation: https://nuxt.com
After generating got this :
Has anyone has the same problem?
Solved with change '&&' with &&
in (location.hostname !== 'localhost' && location.protocol === 'http:')
in style.xsl file
No response
No response
The i18n routes are not generated within the sitemap.xml.
SEE: @funken-studio/sitemap-nuxt-3
https://stackblitz.com/edit/github-zph3d4?file=.output/public/sitemap.xml
yarn build
open ./.output/public/sitemap.xml
System:
OS: macOS 13.1
CPU: (10) arm64 Apple M1 Pro
Memory: 95.58 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.2.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.19.3 - /opt/homebrew/bin/npm
Browsers:
Chrome: 109.0.5414.87
Firefox: 103.0.2
Safari: 16.2
yarn
Google Search Console is reporting issues with the <image:image>
tags in my sitemap. I don't really need them anyways, so I would like the ability to disable them.
Add a new config option to allow users to disable this feature.
No response
No response
On the default endpoint for dynamic URLs, I've successfully generate a sitemap with hardcoded JSON data, but when I fetch the data asynchronously from an external API, the /sitemap.xml page spins endlessly, and does not give any errors as to why. My sitemap configuration is minimal, so I have chosen to omit that portion for simplicity. I'm running [email protected] with [email protected]. I'm not prerendering but I do have server-side rendering enabled in my nuxt.config.ts, so not sure if this has anything to do with it. Do you think this could be bug-related?
import StrapiAPICaller from '~/repository/modules/strapi';
export default cachedEventHandler(
async () => {
const config = useRuntimeConfig();
const strapiBaseUrl = config.public.strapiBaseUrl;
const strapiAPIToken = config.public.strapiAPIToken;
// create a new instance of $fetcher with custom option
const strapiFetcher = $fetch.create({
baseURL: `${strapiBaseUrl}/api`,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + strapiAPIToken,
}
});
// create new instance of strapi api caller
const apiCaller = new StrapiAPICaller(strapiFetcher);
const [blogs, categories, tags, writers] = await Promise.all([
await apiCaller.getBlogPosts(),
await apiCaller.getBlogCategories(),
await apiCaller.getBlogTags(),
await apiCaller.getBlogWriters()
]);
const blogsSitemap = blogs.map((blog) => {
return {
loc: `${config.public.siteUrl}/blog/${blog.attributes.slug}`,
lastmod: blog.attributes.updatedAt,
};
});
const categoriesSitemap = categories.map((category) => {
return {
loc: `${config.public.siteUrl}/category/${category.attributes.slug}`,
lastmod: category.attributes.updatedAt,
};
});
const tagsSitemap = tags.map((tag) => {
return {
loc: `${config.public.siteUrl}/tag/${tag.attributes.slug}`,
lastmod: tag.attributes.updatedAt,
};
});
const writersSitemap = writers.map((writer) => {
return {
loc: `${config.public.siteUrl}/writer/${writer.attributes.slug}`,
lastmod: writer.attributes.updatedAt,
};
});
return [...blogsSitemap, ...categoriesSitemap, ...tagsSitemap, ...writersSitemap]
},
{
name: 'sitemap-dynamic-urls',
maxAge: 60 * 15 // cache URLs for 15 minutes
}
)
No response
No response
For websites that are hosted in a subdirectory, for example https://example.com/subdirectory/{files}
I configure Nuxt's baseURL and Nitro's publicDir to output the site files in the subdirectory required.
The sitemap.xml references the style.xsl file using an absolute path:
This means that when we have a project that has a subdirectory structure, it cannot find the file because it is looking for
https://example.com/__sitemap__/style.xsl
instead of
https://example.com/subdirectory/__sitemap__/style.xsl
Maybe the href could be a relative path or perhaps use app.baseURL?
In the reproduction:
npm run dev
(and go to /subdirectory/sitemap.xml)or
npm run generate
npm run serve
(and go to /subdirectory/sitemap.xml)Thank you!
https://stackblitz.com/edit/nuxt-starter-wuerx5
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 2.01 GB / 15.85 GB
Binaries:
Node: 18.12.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 110.0.5481.177
Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.57)
Internet Explorer: 11.0.19041.1566
I guess here is for allowing other modules to modify the sitemap. So here probably should be call hook
https://github.com/harlan-zw/nuxt-simple-sitemap/blob/79807da608df89d2765bf891254baf97414660d1/src/module.ts#LL129C9-L129C66
We wanted to generate a sitemap index with 2 sitemaps:
How can we achieve this?
I tried to split this with the sitemaps
key (https://github.com/harlan-zw/nuxt-simple-sitemap#multiple-sitemap-support), but this doesn't seem to take any effect (#49).
When using Nitro with preset: node-server
, the sitemap is accessible via /sitemap.xml.
However, when using preset:firebase
and publishing to Firebase Hosting, trying to access /sitemap.xml
returns a 404 error.
Before going deeper in implementing a reproduction, I wanted to know if this is an expected behavior or if I should use a different configuration.
Thank you! :)
No response
"nuxt-simple-sitemap": "^2.4.14"
System:
OS: macOS 13.2.1
CPU: (8) arm64 Apple M2
Memory: 65.20 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.19.0 - /usr/local/bin/node
npm: 8.19.2 - /opt/homebrew/bin/npm
Browsers:
Brave Browser: 112.1.50.121
Chrome: 112.0.5615.137
Safari: 16.3
I have sitemap.xml return error 500 on SSR:true (working well with SSR:false).
I had to go back to previous version v2.4.21 to get it working on SSR true
No response
No response
Some dynamic routes are added multiple times in my sitemap.xml. Here's an example :
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>http://localhost:3000/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/cinquieme/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/cinquieme/enchainement-operations/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/cinquieme/nombres-relatifs/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/cinquieme/parallelogrammes/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/cinquieme/proportionnalite/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/cinquieme/symetries/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/cinquieme/triangles/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/sixieme/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/sixieme/addition-soustraction-multiplication/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/sixieme/distance-cercle/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/sixieme/droites/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/sixieme/longueur-perimetre/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/sixieme/nombres-decimaux/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/sixieme/nombres-entiers/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/troisieme/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/troisieme/arithmetique/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/troisieme/fonctions/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/troisieme/statistiques/</loc>
</url>
<url>
<loc>http://localhost:3000/cours/troisieme/triangles/</loc>
</url>
<url>
<loc>http://localhost:3000/prof/</loc>
</url>
<url>
<loc>http://localhost:3000/prof/</loc>
</url>
</urlset>
Notice the the second and the third URLs as well as the last two URLs. Some routes are dynamic, here's my pages folder structure :
pages/
├── cours/
│ ├── [level]/
│ │ ├── [slug].vue
│ │ └── index.vue
│ └── index.vue
├── prof/
│ ├── agenda.vue
│ ├── cours.vue
│ ├── index.vue
│ └── tableau-blanc.vue
├── 404.vue
└── index.vue
No response
System:
OS: Windows 10 10.0.22621
CPU: (12) x64 AMD Ryzen 5 5600H with Radeon Graphics
Memory: 5.97 GB / 15.35 GB
Binaries:
Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.1.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.963.0), Chromium (108.0.1462.54)
Internet Explorer: 11.0.22621.1
### Used Package Manager
npm
### Validations
- [X] Follow our [Code of Conduct](https://github.com/harlan-zw/.github/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guide](https://github.com/antfu/contribute).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- [X] The provided reproduction is a [minimal reproducible](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
The module only generates static routes when deployed on Netlify, not the pre-rendered ones.
It works fine in a local environment, though.
You may need to add a base dir when calling $fetch
on line 100 of src/runtime/util/entries.ts
:
prerenderedRoutesPayload = await $fetch('/__sitemap__/routes.json')
No response
- Operating System: `Darwin`
- Node Version: `v19.7.0`
- Nuxt Version: `3.3.3`
- Nitro Version: `2.3.2`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `typescript`, `modules`, `generateSvgsViewboxes`, `i18n`, `svgo`, `image`, `robots`, `sitemap`, `feed`, `runtimeConfig`, `vue`, `vite`, `nitro`, `routeRules`, `css`, `app`
- Runtime Modules: `~~/modules/download-global/index.ts`, `~~/modules/download-routes-params/index.ts`, `~~/modules/cms-redirections/index.ts`, `~~/modules/generate-svgs-viewboxes/index.ts`, `~~/modules/lite-youtube-embed/index.ts`, `~~/modules/feed/index.ts`, `@nuxtjs/[email protected]`, `[email protected]`, `@nuxt/[email protected]`, `[email protected]`, `[email protected]`
- Build Modules: `-`
Hi,
I have problem autogenerating with i18n :
ex, it's generate :
<xhtml:link rel="alternate" hreflang="fr" href="https://google.com/bonjour" />
but prefix fr missing, must be :
<xhtml:link rel="alternate" hreflang="fr" href="https://google.com/fr/bonjour" />
Thanks
i18n + differents locales with prefix
- Operating System: Darwin
- Node Version: v19.8.1
- Nuxt Version: 3.5.0
- Nitro Version: 2.4.1
- Package Manager: [email protected]
- Builder: vite
- User Config: css, postcss, typescript, plugins, modules, plausible, i18n, build
- Runtime Modules: @nuxtjs/[email protected], @nuxtjs/[email protected]
- Build Modules: -
i18n support is quite complicated, there's many edge cases and moving parts.
This issue will be used to track general i18n support, including support for all i18n strategies.
As a developer, who migrating from nuxt2 to nuxt3, i want nuxt sitemap module that can generate multiple sitemaps.
There is sitemap module for nuxt 2 with multi-sitemap support: https://sitemap.nuxtjs.org/usage/sitemap-index#setup-a-list-of-sitemaps
No response
No response
I have set up my build with two languages (English and German) and I am struggling to generate the dynamic routes in the sitemap for each page as "/en/{pagename}" and "/de/{pagename}" or for the blog posts as "/en/blog/{blogpostname}" and "/de/blog/{blogpostname}" respectively. They are not coming through on the sitemap, and I feel like I miss something on the basic set-up or understanding, that is preventing them from coming through.
I made a reproduction here: https://stackblitz.com/edit/nuxt-starter-uhq2jp?file=nuxt.config.ts
The blog posts are being fetched from contentful, but in the reproduction I am just using the data array to keep it simple.
Really appreciate any help or perhaps there is already an existing example version online.
Greetings from Germany!
Hello there, I have one question regarding dynamic sitemap generation.
I have been using the sitemap:urls function for applying dynamic content to sitemap.xml. It is working very well in the dev environment but whenever I send it to the production environment it generates a sitemap in the build pipeline and later it is not updating the sitemap by this method.
So, what I expect from sitemap:urls method is actually it should be invoked and sitemap.xml should be updated after the app starts. Is it possible to do that?
Best regards,
Alim
Having the issue with the generation of dynamic URLs, using Handling dynamic URLs method.
Initializing the sitemap module in the nuxt.config.ts
sitemap: { siteUrl: 'https://website.com, autoLastmod: false, },
In the server/api/_sitemap-urls.ts
export default cachedEventHandler(async e => {
const products = await $fetch('https://ap, {
method: 'GET'
})
return products.map((p: any) => {
loc: p.get_absolute_url
})
}, {
name: 'sitemap-dynamic-urls',
maxAge: 60 * 10 // cache URLs for 10 minutes
})
API returns the urls like:
{
"get_absolute_url": "url1"
}
{
"get_absolute_url": "url2"
}
{
"get_absolute_url": "url3"
}
However, after the project building the sitemap.xml generated only existing routes that are located in the pages folder, without fetching routes from the API and including them in the sitemap
It was also noted that the original example of Handling dynamic URLs throws an error
Error: Transform failed with 1 error: nitro 22:35:42
F:\project\server\api\_sitemap-urls.ts:12:75: ERROR: Expected ";" but found ":"
Install Nuxt 3.3.1 alongside nuxt-simple-sitemap 2.4.11, create the server api to fetch dynamic urls
No response
It would be great to use other routes than /api/_sitemap-urls
for handling dynamic URLs.
In our project, the routes with prefix /api
are used differently and collide with the hardcoded server/api/_sitemap-urls.ts
.
If possible, a configuration could be implemented to choose the prefered route.
Here the nuxt documentation describes how to use server routes without the /api
prefix
Maybe this route has to be configurable too: /api/__sitemap__/document-driven-urls
I would love to hear your thoughts on this topic.
No response
No response
I am currrently moving a small project from nuxt 2 -> nuxt 3 and saw that the @nuxtjs/sitemap module is not maintained. So I moved over to this and everything works fine. Except, I had a lastmod date default in my config, to add this date to all entries.
I could not find a way to archive this in this module. Maybe this is by design, and the lastmod date is not required for sitemaps. If so, I'll add a PR to the docs of this module to point this out.
If you think this option is also useful, I can submit a PR for it.
sitemap
option, but thesitemap.defaults
option is not available.sitemap: {
hostname: "https://example.com",
defaults: { lastmod: new Date() },
}
routeRules: {
'/': { sitemap: { changefreq: 'weekly', priority: 1, lastmod: new Date() } },
},
No response
No response
I have followed
https://github.com/harlan-zw/nuxt-simple-sitemap#handling-dynamic-urls
Both api routes and Start-time dynamic URLs just cannot seem to work.
No response
No response
I just installed the latest version of the module and I am getting a weird issue on my deployment website that does not happen locally.
I am using _sitemap-urls endpoint to load dynamically my blog pages. In development, both my dynamic and my non-dynamic pages appear:
It works:
nuxi dev
nuxi generate
nuxi build
and then open locally with node ./output/server/index.mjs
However, it fails when I deploy on my server: only the dynamics urls are shown:
Versions of node are roughly the same, though OS differ :
Windows 11
with node 18.13
in local for dev and build18.14.1
on deployed server.The logs are empty, except they confirm (via a console.log
) that the sitemap-urls
endpoint is called.
I can't wrap my head around what's happening. Any clue for me to test and gather more information would be welcome. 😄
No response
Nuxi 3.3.1 Nuxt project info:
------------------------------
- Operating System: `Windows_NT`
- Node Version: `v18.13.0`
- Nuxt Version: `3.3.1`
- Nitro Version: `2.3.1`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `app`, `modules`, `css`, `build`, `googleFonts`, `sitemap`
- Runtime Modules: `@nuxt/[email protected]`, `@nuxtjs/[email protected]`, `@nuxtjs/[email protected]`, `[email protected]`
- Build Modules: `-`
------------------------------
Hey, thanks for open-sourcing this awesome module! Unfortunately, I'm facing some issues and I'm hoping you could help me sort them out. I've tested all versions between 2.4.11 and 2.4.15. In 2.4.11 everything was working except in the production build the siteUrl was prepended twice to the path in each location.
In dev mode everything was working fine.
in 2.4.12-2.4.14 Some imports were missing and the module was not working at all.
In 2.4.15 I see the same issue with urls as in 2.4.11, but additionally, the dev mode stopped working. I'm getting 404 errors with the following error:
[nuxt] [request error] [unhandled] [404] (404 Page Not Found (/__sitemap__/routes.json)) 12:08:13 PM
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async generateSitemapEntries (./.nuxt/dev/index.mjs:757:32)
at async buildSitemap (./.nuxt/dev/index.mjs:795:14)
at async ./.nuxt/dev/index.mjs:1066:10
at async Object.handler (./node_modules/h3/dist/index.mjs:1247:19)
at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:1322:7)
I think that the nuxt config is implemented correctly:
sitemap: {
siteUrl: process.env.APP_DOMAIN ?? 'localhost:8080',
},
and my .env file contains:
NUXT_PUBLIC_APP_DOMAIN=localhost:8080
Will try to prepare one tomorrw
Probably irrelevant:
System:
OS: Linux 5.19 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12400
Memory: 14.24 GB / 31.13 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn
npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm
Browsers:
Chrome: 112.0.5615.49
Firefox: 112.0.2
So, as stated in the nuxt-seo-kit I've noticed that simple-sitemap needs to prerender all the pages so that it could create the sitemap. Quite fine for SSG but not so much when on SSR with SWR and ISR...
So I started studying how dynamic urls setup works, but if I understand it correctly, for the loc
I should provide the slug and not the full url right? But then where I put the full url? In the sitemap.siteUrl
inside nuxt.config.ts
? But if I do so doesn't it reactivate the prerendering?
Is there any option to set sitemap as a xml file? I would like to use real XML in production.
Can you provide or is there an option to use non styled sitemap in production?
My nuxt.config.ts
is
sitemap: {
siteUrl: 'https://xxx',
urls: () => posts.map(item => ({
loc: `/post/${item[0]}`,
lastmod: new Date(),
priority: 0.6,
})),
},
Then I check https://xxx/sitemap.xml
, I can only see 3 columns named URL
Images
and Last Mod.
How can I know if priority work? Is other pages with priority 1 by default?
Getting a "Hydration completed but contains mismatches" console error when doing a refresh in production.
When the website is open for the first time and even after doing page navigation the warning does not appear. But once I do a refresh then the console error happens.
I do have dynamic routes and they all seem to be generated on build, don't know if that could be the cause.
This problem started right after installing and configuring the module, removing it solves the issue.
No response
System:
OS: Windows 10 10.0.19044
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chromium (108.0.1462.76)
npm
Using the addon with nuxt content results in a rendering error and boat load of random pages.
Adding the sitemap addon to the official Nuxt Content stackblitz https://stackblitz.com/edit/github-9layqu
(Based on the sitemap it seems to be <!DOCTYPE included in the sitemap)
No response
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/__sitemap__/style.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://localhost:3000/0</loc>
</url>
<url>
<loc>http://localhost:3000/1</loc>
</url>
<url>
<loc>http://localhost:3000/2</loc>
</url>
<url>
<loc>http://localhost:3000/3</loc>
</url>
<url>
<loc>http://localhost:3000/4</loc>
</url>
<url>
<loc>http://localhost:3000/5</loc>
</url>
<url>
<loc>http://localhost:3000/6</loc>
</url>
<url>
<loc>http://localhost:3000/7</loc>
</url>
<url>
<loc>http://localhost:3000/8</loc>
</url>
<url>
<loc>http://localhost:3000/9</loc>
</url>
<url>
<loc>http://localhost:3000</loc>
</url>
<url>
<loc>http://localhost:3000/!</loc>
</url>
<url>
<loc>http://localhost:3000/D</loc>
</url>
<url>
<loc>http://localhost:3000/O</loc>
</url>
<url>
<loc>http://localhost:3000/C</loc>
</url>
<url>
<loc>http://localhost:3000/T</loc>
</url>
<url>
<loc>http://localhost:3000/Y</loc>
</url>
<url>
<loc>http://localhost:3000/P</loc>
</url>
<url>
<loc>http://localhost:3000/E</loc>
</url>
<url>
<loc>http://localhost:3000/h</loc>
</url>
<url>
<loc>http://localhost:3000/t</loc>
</url>
<url>
<loc>http://localhost:3000/m</loc>
</url>
<url>
<loc>http://localhost:3000/l</loc>
</url>
<url>
<loc>http://localhost:3000/e</loc>
</url>
<url>
<loc>http://localhost:3000/a</loc>
</url>
<url>
<loc>http://localhost:3000/d</loc>
</url>
<url>
<loc>http://localhost:3000/c</loc>
</url>
<url>
<loc>http://localhost:3000/r</loc>
</url>
<url>
<loc>http://localhost:3000/s</loc>
</url>
<url>
<loc>http://localhost:3000/=</loc>
</url>
.....
<!-- XML Sitemap generated by Nuxt Simple Sitemap -->
I have set up the site map as outlined here https://stackblitz.com/edit/nuxt-starter-dyraxc?file=package.json, https://github.com/harlan-zw/nuxt-simple-sitemap and also followed this example here: https://github.com/harlan-zw/harlanzw.com/blob/main/server/routes/feed.atom.ts
export default defineNuxtConfig({
extends: ["nuxt-seo-kit"],
modules: [
"@nuxtjs/tailwindcss",
"nuxt-meilisearch",
"@pinia/nuxt",
"nuxt-mapbox",
"@unlighthouse/nuxt",
"nuxt-jsonld",
"@nuxtjs/apollo",
],
runtimeConfig: {
public: {
siteUrl: process.env.NUXT_PUBLIC_SITE_URL || "https://foobar.com",
},
nitro: {
serveStatic: true,
prerender: {
crawlLinks: true,
routes: [
'/',
]
}
},
sitemap: {
sitemaps: true,
include: [
'/data/**',
],
},
The dynamic configuration should. be sourced from server/api/_sitemap-urls.ts
:
export default cachedEventHandler(
async (e) => {
const posts = await Promise.all([
{
_path: '/blog/post-a',
modifiedAt: new Date(),
},
]);
return posts.map((p) => {
return {
loc: p._path,
lastmod: p.modifiedAt,
};
});
},
{
name: 'sitemap-dynamic-url',
maxAge: 60 * 10, // cache URLs for 10 minutes
}
);
For now, this is only a dummy dynamic config - but it should be created using a GRAPHQL call in the future using apollo.
sitemap.include
array are presentOnly the routes (static ones) which are generated by default are created.
No response
nuxt: 3.5.2
Tried to create multiple sitemaps with the following code in the nuxt config:
sitemap: {
// manually chunk into multiple sitemaps
sitemaps: {
posts: {
include: [
'/blog/**',
],
// example: give blog posts slightly higher priority (this is optional)
defaults: { priority: 0.7 },
},
pages: {
exclude: [
'/blog/**',
]
},
},
},
This is not making any difference. It is by default generating the default sitemap. Even If remove the above config, no changes in the sitemap generated.
I'm generating the static build with npm run generate
.
Btw, I'm using nuxt-seo-kit
for the sitemap generation.
No response
Nuxt: v3.3.1
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 2.02 GB / 15.84 GB
Binaries:
Node: 16.19.0 - C:\Program Files\nodejs\node.EXE
npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.1555.0), Chromium (113.0.1774.42)
Internet Explorer: 11.0.22621.1
I'm hosting my nuxt app as SSR in AWS Lambda. When I do the nuxt build
, the process is generating the __sitemap__/routes.json
under the public and this is part of the package deployed to the lambda. But when I access the sitemap, it throws this error in the logs and the website return a 404 page.
2023-05-20T01:04:09.593Z 9b2aa494-9714-49ba-9c9c-406a52a37d05 WARN [Vue Router warn]: No match found for location with path "/__sitemap__/routes.json"
Attached the lambda package content screenshot from AWS console.
No response
- Operating System: `Darwin`
- Node Version: `v18.14.0`
- Nuxt Version: `3.5.0`
- Nitro Version: `2.4.1`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `runtimeConfig`, `modules`, `sitemap`, `meta`, `nitro`, `server`, `css`, `build`
- Runtime Modules: `[email protected]`, `@nuxtjs/[email protected]`, `@nuxtjs/[email protected]`
- Build Modules: `-`
I made a function that creates dynamic routes with various number of URLs. And, after this npm run dev started taking too long to process since it's generating the sitemap preview for each build. Is it possible to only generate a sitemap on nuxt build command?
['nuxt-simple-sitemap',
{
hostname: process.env.BASE_URL,
urls: () => {
return Promise.all([
axios.get(URL),
]).then(([courses]) => {
return [
convertObjToSitemapByCourse(courses, 'course', 'monthly'),
].reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
}).catch((e) => {
console.log(e);
});
}
}
]
Hi,
I'm developing a multilingual website and I need to create a sitemap which contains the localized versions of every page. I found this issue https://github.com/harlan-zw/nuxt-simple-sitemap/issues/11, so I tought it was possible and I created server/api/_sitemap-urls.ts
:
export default cachedEventHandler(async e => {
return [
{
loc: '/page-1'
},
{
loc: '/page-2',
links: [
{
lang: 'en',
href: '/en/page-2'
},
],
}
];
}, {
name: 'sitemap-dynamic-urls',
maxAge: 60 * 10 // cache URLs for 10 minutes
})
But it generates this sitemap
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/__sitemap__/style.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://localhost:3000</loc>
</url>
<url>
<loc>http://localhost:3000/page-1</loc>
</url>
<url>
<loc>http://localhost:3000/page-2</loc>
<links:links>
<links:lang>en</links:lang>
<links:href>/en/page-2</links:href>
</links:links>
</url>
</urlset>
<!-- XML Sitemap generated by Nuxt Simple Sitemap -->
Instead it should be something like
<url>
<loc>http://localhost:3000/page-2</loc>
<xhtml:link
rel="alternate"
hreflang="en"
href="http://localhost:3000/en/page-2"/>
</url>
Am I doing something wrong or is it just not possible to generate a sitemap with xhtml:link elements?
Currently it is possible in nuxt to ignore pages with the ignorePrefix
option in nuxt.config.js
(https://nuxt.com/docs/api/configuration/nuxt-config#ignoreprefix). It would be nice if this module would exclude those pages automatically from the sitemap.
An easy solution would be to find glob pattern that match the ignorePrefix
. Something like this (does not work for me):
export default defineNuxtConfig({
sitemap: {
exclude: [
'/**/-*',
'/-*',
],
},
});
Maybe .nuxtignore
could also be relevant for this: https://nuxt.com/docs/guide/directory-structure/nuxtignore
No response
I am currently developing a multilingual website using @nuxtjs/i18n and @nuxtjs/prismic.
The project in in SSR mode, and while waiting for a proper i18n support, the possibility to manually add alternate versions of a page in the sitemap would be really helpful.
sitemap: {
// provide dynamic URLs to be included
urls: async () => {
const blogPages = await getBlogPages()
return blogPages.map((page) => ({
url: `/blog/${page.slug}`,
lastmod: page.updatedAt,
changefreq: 'daily',
priority: 0.8,
XHTMLLinks: [
{
rel: 'alternate',
hreflang: 'fr',
// I guess this would need to be a full url to support i18n's differentDomains feature
href: `https://www.example.com/fr/blog/alternate-slug`
},
// ...
],
}))
},
},
No response
No response
Module does not work correctly in development mode. In Production mode everything is fine.
const { SitemapStream, streamToPromise } = pkg;
import { SitemapStream, streamToPromise } from 'node_modules/sitemap/dist/index.js'; 17:11:18
^^^^^^^^^^^^^
SyntaxError: Named export 'SitemapStream' not found. The requested module 'node_modules/sitemap/dist/index.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'node_modules/sitemap/dist/index.js';
const { SitemapStream, streamToPromise } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
ℹ Vite client warmed up in 1991ms
No response
System:
OS: macOS 12.2.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.20 GB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.12.1 - /usr/local/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.19.2 - /usr/local/bin/npm
Browsers:
Chrome: 109.0.5414.119
Firefox: 108.0.1
Safari: 15.3
npm
I am running Nuxt within a Docker environment with an Nginx reverse proxy. I do not have a LetsEncrypt certificate or any SSL configured on the reverse proxy, since it is handled by my load balancer in AWS. When I navigate to /sitemap.xml, it is failing with the error:
request to https://website:8080/__sitemap__/routes.json failed, reason: write EPROTO 139859522480944:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:331: (https://website:8080/__sitemap__/routes.json)
The sitemap is failing to fetch the routes.json file, since it is fetching it server-side on an https connection, when in fact there is no SSL on the server. I took a look at the codebase and I believe it is because the host is resolving to my Docker container named 'website', instead of 'localhost' or '127.0.0.1', which sets the useHTTP flag to false. This is probably an edge case that hasn't been considered, but wanted to bring it to your attention in case it is a bug or defect.
No response
No response
By default nuxt-simple-sitemap generates pages components urls.
This clashes with pre-rendered routes and i18n.
We should be able to disable default urls generation (prevent generateUrls function from running) without excluding them one by one.
yarn build
open ./.output/public/sitemap.xml
System:
OS: macOS 13.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.37 GB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.2.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.19.3 - /opt/homebrew/bin/npm
Browsers:
Chrome: 109.0.5414.87
Firefox: 103.0.2
Safari: 16.2
yarn
Bug was introduced here: 659a0d8
Error:
ERROR EISDIR: illegal operation on a directory, open 'C:\Users\Fraser\Websites\2022\mctweb.co.uk\.output\public\sitemap.xml'
When nitro.options.prerender.routes.push("/sitemap.xml")
is removed, the module works as expected
No response
System:
OS: Windows 10 10.0.19045
CPU: (16) x64 Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
Memory: 18.43 GB / 31.92 GB
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.18.0 - ~\AppData\Roaming\npm\npm.CMD
yarn
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.