Comments (27)
As of 3.1.3, the i18n logic has been updated:
- will now correctly show all i18n URLs with all hreflangs
- x-default added for default lang
- hreflang will now use the locale iso if available (over the code).
Got it working with this version, all urls now showing up in sitemap!
Thank you Harlan 🎉 😄
from sitemap.
@dargmuesli I am using [email protected]
. Maybe, that's why?
EDIT: I ended up removing @nuxtseo/module
and using directly nuxt-simple-robots
and nuxt-simple-sitemap
.
from sitemap.
In the v4 release there have been many more improvements to i18n. I've updated the i18n documentation here.
I'm going to close this issue off as I believe all major issues are solved, anything further will just be proper documentation.
Please let me know if you have any problems with a new issue and I'll do my best to help.
from sitemap.
Hi,
I have the same problem.
Sorry to ask if already done, but do you have any solution to this? Any update about when this will be solved?
Many thanks!
from sitemap.
Need this also :D Thank you for your work, that's one of the best packages I have used for Nuxt 3.
from sitemap.
I have a nuxt app with 3 locales (ca, en, es) after trying all three strategies i get:
prefix-> the sitemap shows only /** and /en/** which is the default locale.
prefix_and_default -> the sitemap shows only /**
prefix_except_default -> the sitemap shows only /**
from sitemap.
There were a few bugs found around how the i18n integration was working if you were using inline options, these are fixed in 3.0.15.
I've added a docs page for the i18n integration that may provide further help.
Any StackBlitz reproductions you can provide of things not working (you can use https://stackblitz.com/edit/nuxt-starter-jwuie4?file=app.vue as a starter), would be helpful 🙏
from sitemap.
Hi,
I just try your last version (3.1.3), and the update apply about i18n integration are very nice !
I have just one question about include
and exclude
attributes:
When we use multiple custom sitemaps we need to define wich links are added into each sitemap with include
attribute. But with i18n, we need to add all locales availables into include
attribute like this:
sitemaps: {
main: {
include: [
'/en/auth/**', '/en/search/', '/en/privacy-policy', '/en',
'/fr/auth/**', '/fr/search/', '/fr/privacy-policy', '/fr'
]
},
versions: {
include: ['/en/version/**', '/fr/version/**']
},
information: {
include: ['/en/information/**', '/fr/information/**']
}
}
I don't kow if you can manage this case (with a marker for example) to have something like this:
sitemaps: {
main: {
include: ['/[locale]/auth/**', '/[locale]/search/', '/[locale]/privacy-policy', '/[locale]']
},
...
}
Or any other way to handle all locale automatically with include
(and exclude
) attributes.
I make this reproduction stackblitz of this use case.
from sitemap.
Nice, almost there 🤞 3.2.5 is looking better but maybe you can confirm
https://stackblitz.com/edit/nuxt-starter-kq6gnw?file=package.json
from sitemap.
It's working as expected. It's neat! Well done @harlan-zw, you did a great job here! 👏
from sitemap.
Thank you for your amazing help @vdlbk!
I'll keep this open while there's still some outstanding i18n issues.
from sitemap.
I think this might not be needed anymore in v3, if anyone can confirm.
from sitemap.
The update works much better with the content module, It's picking up all the locales!
As for the rest I'm only getting the default route in the sitemap.
Using prefix_except_default
and exactly same experience as mentioned above.
Live sitemap picks up all content based routes with locales but other routes are ignored.
Example:
/blog
- Present
/ko/blog
- Missing
/zh/blog
- Missing
Here's my Configuration / repo
from sitemap.
As of 3.1.3, the i18n logic has been updated:
- will now correctly show all i18n URLs with all hreflangs
- x-default added for default lang
- hreflang will now use the locale iso if available (over the code).
from sitemap.
Hey everyone,
I'm having some issues with dynamic URLs. I cannot seem to find a solution that fixes my problem.
I'm using the i18n strategy prefix
and the dynamic URLs I'm injecting do not have any prefix.
If I consider adding them myself, then the alternative links are wrong and I'd prefer avoiding doing this myself anyway.
"@nuxtjs/i18n": "^8.0.0-beta.13",
"nuxt": "^3.6.5",
"nuxt-simple-sitemap": "^3.1.8",
// nuxt.config.ts
export default defineNuxtConfig({
// ...
i18n: {
strategy: 'prefix',
defaultLocale: 'en',
locales: [
{ code: 'fr', iso: 'fr' },
{ code: 'es', iso: 'es' },
{code: 'en', iso: 'en'}
],
},
site: {
url: 'http://localhost:3000',
},
sitemap: {
autoAlternativeLangPrefixes: true,
xsl: false
}
})
Entry for non-dynamic URL:
<url>
<lastmod>2023-08-03T09:13:24+00:00</lastmod>
<loc>http://localhost:3000/en/definitions</loc>
<xhtml:link rel="alternate" hreflang="fr" href="http://localhost:3000/fr/definitions" />
<xhtml:link rel="alternate" hreflang="es" href="http://localhost:3000/es/definitions" />
<xhtml:link rel="alternate" hreflang="en" href="http://localhost:3000/en/definitions" />
<xhtml:link rel="alternate" hreflang="x-default" href="http://localhost:3000/en/definitions" />
</url>
Entry for dynamic URL injected via server/api/_sitemap-urls.ts
<url>
<lastmod>2023-08-22T13:39:17+00:00</lastmod>
<loc>http://localhost:3000/definitions/river</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="http://localhost:3000/definitions/river" />
<xhtml:link rel="alternate" hreflang="fr" href="http://localhost:3000/fr/definitions/river" />
<xhtml:link rel="alternate" hreflang="es" href="http://localhost:3000/es/definitions/river" />
<xhtml:link rel="alternate" hreflang="en" href="http://localhost:3000/en/definitions/river" />
</url>
The <loc>
is missing the prefix and the x-default
just also has a prefix.
Expected:
<url>
<lastmod>2023-08-22T13:39:17+00:00</lastmod>
<loc>http://localhost:3000/en/definitions/river</loc>
<xhtml:link rel="alternate" hreflang="x-default" href="http://localhost:3000/en/definitions/river" />
<xhtml:link rel="alternate" hreflang="fr" href="http://localhost:3000/fr/definitions/river" />
<xhtml:link rel="alternate" hreflang="es" href="http://localhost:3000/es/definitions/river" />
<xhtml:link rel="alternate" hreflang="en" href="http://localhost:3000/en/definitions/river" />
</url>
Am I missing something?
Thanks for the help!
from sitemap.
Thank you for the detailed post @vdlbk.
I've done some more work on i18n based on what you've sent. Please see the release notes https://github.com/harlan-zw/nuxt-simple-sitemap/releases/tag/v3.2.0
from sitemap.
Hey @harlan-zw! Thanks for the quick reaction, I really appreciate it!
Using 3.2.0, I can change the value of sitemaps
to undefined | true | false
, it gives me every time hasDisabledSitemaps: true
. So it's generating the same sitemap with every link in it (Similar to the problem n°2 I'm mentioning below). With the 3.2.2, it seems to work better.
Still, I tried on Stackblitz and locally on my project, and I have on both the same problems.
-
When
sitemaps === undefined
(or empty), no index sitemap is generated for each locale. Only the default. And we are missing the last updated date. Is that something to do with an i18n configuration now? I'm guessing not.
-
When
sitemaps === false
, some entries are missing the last updated date, and there are wrong links. Looks like some of the locale prefixes are being mixed together sometimes. But we can also see some valid links.
Many thanks for your help and time! 🚀
from sitemap.
Sorry @vdlbk, I tested this out by using locales as a string array (['en', fr']
) without testing for object entries ([{ code: 'en', iso: 'en-AU' }]
) 🤦 Appreciate your screenshots!
Can you please try 3.2.4. I've tested it out on your StackBlitz repo and it looks correct (https://stackblitz.com/edit/nuxt-starter-kq6gnw?file=nuxt.config.ts)
from sitemap.
No worries @harlan-zw, happy to see you spotted quickly the reason behind this!
But I'm curious to understand why we strip non-prefixed URLs instead of adding the prefix? Especially in the prefix strategy where we expect every URL to have a prefix. Does it means for dynamic URLs I should add the prefix myself?
And it does not look to work properly.
In the version 3.2.3, for my example with locales en
and hr
, we can see these 4 URLS :
URL | Comment | valid? |
---|---|---|
http://localhost:3000/en/definitions | Non-dynamic URL | ✔️ |
http://localhost:3000/definitions/river | Dynamic URL missing the locale prefix en |
🔴 |
http://localhost:3000/hr/definitions | Non-dynamic URL | ✔️ |
http://localhost:3000/hr/definitions/river | Dynamic URL with the locale prefix hr |
✔️ |
In the version 3.2.4, the http://localhost:3000/definitions/river
got stripped because it misses the prefix, while http://localhost:3000/hr/definitions/river
no. But as it is also a dynamic URL and has it "received" the prefix somehow, it's not stripped. Do you know why the default locale was not added to dynamic URLs?
Because if I change the defaultLocale
to hr
, then it's the opposite that happens, the en
URL is here and the hr
URL got removed.
The expected output should be the following URLs in the sitemap:
URL | Comment |
---|---|
http://localhost:3000/en | Non-dynamic URL |
http://localhost:3000/hr | Non-dynamic URL |
http://localhost:3000/en/definitions | Non-dynamic URL |
http://localhost:3000/hr/definitions | Non-dynamic URL |
http://localhost:3000/en/definitions/river | Dynamic URL with the locale prefix en |
http://localhost:3000/hr/definitions/river | Dynamic URL with the locale prefix hr |
http://localhost:3000/en/about | Non-dynamic URL |
http://localhost:3000/hr/about | Non-dynamic URL |
Also, do you know why some entries are missing the last update date?
Adding the defaults
configuration does not change the deal.
from sitemap.
there isn't a compostable that i can use to set dynamic custom alternative language directly on the page?
I have a blog but the articles URL are different for every lang
Example:
// blog section
en/blog/a-simple-article
it/blog/un-semplice-articolo
de/blog/een-eenvoudig-artikel
// guide section
en/guide/a-simple-guide
it/guide/una-semplice-guide
de/guide/een-eenvoudig-handleiding
// case-study section
en/case-study/a-simple-post
it/case-study/un-semplice-post
de/case-study/een-eenvoudig-post
What's the best practice to implement alternate langs in this case?
from sitemap.
@harlan-zw I was using nuxt-seo-kit and it was not the version 3 for nuxt-simple-sitemap.
https://github.com/harlan-zw/nuxt-seo-kit/blob/main/layer/package.json
from sitemap.
@LeCoupa are you using @nuxtseo/module
v2.0.0-beta
?
from sitemap.
@luca-smartpricing I am facing the same problem, Could you solve it?
from sitemap.
there isn't a compostable that i can use to set dynamic custom alternative language directly on the page? I have a blog but the articles URL are different for every lang Example:
// blog section en/blog/a-simple-article it/blog/un-semplice-articolo de/blog/een-eenvoudig-artikel // guide section en/guide/a-simple-guide it/guide/una-semplice-guide de/guide/een-eenvoudig-handleiding // case-study section en/case-study/a-simple-post it/case-study/un-semplice-post de/case-study/een-eenvoudig-post
What's the best practice to implement alternate langs in this case?
You can use the i18n.pages
config or the defineI18n
composable, just make sure you set the strategy to no_prefix
I think
from sitemap.
Hi 👋
I'm having some issues with i18n support. Please find below a partial from my en-US-sitemap.xml
. Notice the lines marked with ❌, these urls/pages do not exist. I've been using Vue for years but its my first time using Nuxt and this sitemap package, so its totally possible I am doing something silly.
Fwiw the blog articles are coming from nuxt/content and slugs are localized /blog/article-two
in English language would be /es/blog/article-two-es
in Spanish language..
<url>
<lastmod>2023-10-17T22:19:43+00:00</lastmod>
✅ <loc>http://localhost:3001/blog/article-two</loc>
✅ <xhtml:link rel="alternate" hreflang="en-US" href="http://localhost:3001/blog/article-two" />
❌ <xhtml:link rel="alternate" hreflang="es-ES" href="http://localhost:3001/es/blog/article-two" />
❌ <xhtml:link rel="alternate" hreflang="nl-NL" href="http://localhost:3001/nl/blog/article-two" />
✅ <xhtml:link rel="alternate" hreflang="x-default" href="http://localhost:3001/blog/article-two" />
</url>
<url>
<lastmod>2023-10-17T22:31:15+00:00</lastmod>
❌ <loc>http://localhost:3001/blog/article-two-es</loc>
❌ <xhtml:link rel="alternate" hreflang="en-US" href="http://localhost:3001/blog/article-two-es" />
✅ <xhtml:link rel="alternate" hreflang="es-ES" href="http://localhost:3001/es/blog/article-two-es" />
❌ <xhtml:link rel="alternate" hreflang="nl-NL" href="http://localhost:3001/nl/blog/article-two-es" />
❌ <xhtml:link rel="alternate" hreflang="x-default" href="http://localhost:3001/blog/article-two-es" />
</url>
<url>
<lastmod>2023-10-17T22:31:15+00:00</lastmod>
❌ <loc>http://localhost:3001/blog/article-two-nl</loc>
❌ <xhtml:link rel="alternate" hreflang="en-US" href="http://localhost:3001/blog/article-two-nl" />
❌ <xhtml:link rel="alternate" hreflang="es-ES" href="http://localhost:3001/es/blog/article-two-nl" />
✅ <xhtml:link rel="alternate" hreflang="nl-NL" href="http://localhost:3001/nl/blog/article-two-nl" />
❌ <xhtml:link rel="alternate" hreflang="x-default" href="http://localhost:3001/blog/article-two-nl" />
</url>
This is the i18n package in my deps.
npm:@nuxtjs/i18n-edge@^8.0.0-rc.4-28265986.9dae464
// nuxt.config.js
sitemap: {
autoI18n: true,
strictNuxtContentPaths: true,
discoverImages: false,
},
If I set autoI18n: false
I get a single sitemap.xml
with all urls including proper i18n paths which actually is perfectly fine, perhaps I should just not use autoI18n
..
Thank you for the efforts! 🙌
from sitemap.
我的i18n设置了domain模式,在这种情况下启用autoI18n,sitemap中不能得到正确的网页地址。
from sitemap.
There is a problem where I want to set up a sitemap using the dynamic URLs feature, and the URLs are different in different languages, how to avoid generating all versions of this URL?
from sitemap.
Related Issues (20)
- Nuxt content paths are still added when setting documentDriven false HOT 2
- some sitemap is not need to be automatically sorted HOT 1
- Create sitemap index at runtime HOT 1
- Problem with i18n integration HOT 1
- Would it be possible to have a sitemap filter by layout type? HOT 1
- Sitemap not compatible with definePageMeta().path HOT 1
- 404 deployed on Vercel HOT 1
- When using the '@nuxtjs/i18n' plugin on Cloudflare Pages, errors occur. HOT 3
- Pages are logged in the console when running yarn dev or yarn build HOT 1
- Not able to set hostname to the sitemaps HOT 8
- Inability to exclude specific routes while including others
- [Feature Request] Perform paging processing under multiple sources HOT 2
- Generate sitemap with CLI HOT 2
- Ignoring sitemap for entire locale using nuxt i18n HOT 1
- specify custom source for dynamic URL's and set alternate
- excluded urls are not excluded from alternate entry HOT 3
- Type issue when importing module HOT 4
- Headers are not sent when set from sources
- Sitemap generation is drastically slower after version `5.1.5` HOT 1
- When generating, ${BASE_URL}/sitemap.xml is being called HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sitemap.