Code Monkey home page Code Monkey logo

Comments (27)

xanzhu avatar xanzhu commented on July 30, 2024 2

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.

LeCoupa avatar LeCoupa commented on July 30, 2024 2

@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.

harlan-zw avatar harlan-zw commented on July 30, 2024 2

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.

GuillaumeDgr avatar GuillaumeDgr commented on July 30, 2024 1

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.

LeCoupa avatar LeCoupa commented on July 30, 2024 1

Need this also :D Thank you for your work, that's one of the best packages I have used for Nuxt 3.

from sitemap.

marcbejar avatar marcbejar commented on July 30, 2024 1

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.

harlan-zw avatar harlan-zw commented on July 30, 2024 1

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.

NtchPlayer avatar NtchPlayer commented on July 30, 2024 1

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.

harlan-zw avatar harlan-zw commented on July 30, 2024 1

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.

vdlbk avatar vdlbk commented on July 30, 2024 1

It's working as expected. It's neat! Well done @harlan-zw, you did a great job here! 👏

from sitemap.

harlan-zw avatar harlan-zw commented on July 30, 2024 1

Thank you for your amazing help @vdlbk!

I'll keep this open while there's still some outstanding i18n issues.

from sitemap.

harlan-zw avatar harlan-zw commented on July 30, 2024

I think this might not be needed anymore in v3, if anyone can confirm.

from sitemap.

xanzhu avatar xanzhu commented on July 30, 2024

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.

harlan-zw avatar harlan-zw commented on July 30, 2024

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.

vdlbk avatar vdlbk commented on July 30, 2024

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.

See on Stackblitz

"@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.

harlan-zw avatar harlan-zw commented on July 30, 2024

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.

vdlbk avatar vdlbk commented on July 30, 2024

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.

  1. 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.
    1
    2
    3

  2. 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.
    4

Many thanks for your help and time! 🚀

from sitemap.

harlan-zw avatar harlan-zw commented on July 30, 2024

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.

vdlbk avatar vdlbk commented on July 30, 2024

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.

luca-smartpricing avatar luca-smartpricing commented on July 30, 2024

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.

LeCoupa avatar LeCoupa commented on July 30, 2024

@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.

dargmuesli avatar dargmuesli commented on July 30, 2024

@LeCoupa are you using @nuxtseo/module v2.0.0-beta?

from sitemap.

argenisleon avatar argenisleon commented on July 30, 2024

@luca-smartpricing I am facing the same problem, Could you solve it?

from sitemap.

harlan-zw avatar harlan-zw commented on July 30, 2024

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.

laygir avatar laygir commented on July 30, 2024

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.

gaoxu529 avatar gaoxu529 commented on July 30, 2024

我的i18n设置了domain模式,在这种情况下启用autoI18n,sitemap中不能得到正确的网页地址。

from sitemap.

everyx avatar everyx commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.