Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当i18n DifferentDomains 为True时生成的站点地图内容不正确 #172

Closed
gaoxu529 opened this issue Nov 23, 2023 · 10 comments
Closed

Comments

@gaoxu529
Copy link

Describe the bug

这是当i18n DifferentDomains 为True时生成的站点地图,如下图所示:
image
然而,正确的格式应该是这样的:

hourly 2023-11-20T09:42:24+00:00 https://www.footballant.com/ hourly 2023-11-20T09:42:24+00:00 https://www.footballant.com/about

Reproduction

No response

System / Nuxt Info

No response

@harlan-zw
Copy link
Collaborator

Please share your i18n config.

@gaoxu529
Copy link
Author

gaoxu529 commented Nov 23, 2023

以下是我的i18n配置示例

i18n: {
    compilation: {
      strictMessage: false 
    },
    baseUrl: process.env.BASE_URL,
    locales: [
      {
        code: 'en',
        name: 'English',
        iso: 'en',
        file: 'en/pc.js',
        domain: 'www.test.com'
      },
      {
        code: 'fr',
        name: 'Français',
        iso: 'fr',
        file: 'fr/pc.js',
        domain: 'fr.test.com'
      },
      {
        code: 'it',
        name: 'Italiano',
        iso: 'it',
        file: 'it/pc.js',
        domain: 'it.test.com'
      },
      {
        code: 'pt',
        name: 'Portuguese',
        iso: 'pt',
        file: 'pt-PT/pc.js',
        domain: 'pt.test.com'
      }
    ],
    differentDomains: true,
    detectBrowserLanguage: false,
    defaultLocale: 'en',
    langDir: 'lang/',
    lazy: true
  },

@harlan-zw
Copy link
Collaborator

Why are the domains not wrapped in strings? Can you try and provide a StackBlitz reproduction https://stackblitz.com/edit/nuxt-starter-jwuie4?file=app.vue

@gaoxu529
Copy link
Author

这个是发评论时 漏掉了 引号。

Why are the domains not wrapped in strings? Can you try and provide a StackBlitz reproduction https://stackblitz.com/edit/nuxt-starter-jwuie4?file=app.vue

@gaoxu529
Copy link
Author

我在 https://stackblitz.com/edit/nuxt-starter-jwuie4?file=app.vue 中完善了示例代码,生成的站点地图
hr-HR-sitemap.xml和en-US-sitemap.xml从浏览器中看到的是正确的,但是在这个里面我无法使用类似浏览器的查看源码功能查看这两个文件的源文件,我所描述的错误是在这两个文件的源文件中体现的。

@gaoxu529
Copy link
Author

gaoxu529 commented Nov 23, 2023

@harlan-zw

我找到 hr-HR-sitemap.xml 的源码了,
可以在浏览器中直接打开
https://nuxtstarterj9rgqk-l4mt--3000--9e24d36e.local-corp.webcontainer.io/hr-HR-sitemap.xml ,然后F12 查看源码。

现在生成的格式如下:

<?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:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" 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>https://hr.test.com/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://hr.test.com/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/" />
    </url>
    <url>
        <loc>https://hr.test.com/about/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://hr.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/about/" />
    </url>
</urlset>
<!-- XML Sitemap generated by Nuxt Simple Sitemap v4.1.6 -->

正确的格式应该是:

<?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:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" 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>https://hr.test.com/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://www.test.com/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/" />
    </url>
    <url>
        <loc>https://hr.test.com/about/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://www.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/about/" />
    </url>
</urlset>
<!-- XML Sitemap generated by Nuxt Simple Sitemap v4.1.6 -->

@PabloGBarcelo
Copy link
Contributor

Hey @gaoxu529, is this happening in the latest version (v5)?
(please, if it's possible answer in english, or use chatgpt, it's easier to track the issue)

@gaoxu529
Copy link
Author

@PabloGBarcelo

Yes, this occurred in V5.
My question is: the sitemap content generated when i18n DifferentDomains is set to True is incorrect.

I have improved the example code at https://stackblitz.com/edit/nuxt-starter-jwuie4?file=app.vue.
It can be opened directly in the browser at
https://nuxtstarterj9rgqk-l4mt--3000--9e24d36e.local-corp.webcontainer.io/hr-HR-sitemap.xml, and then you can view the source code by pressing F12.

The format that is currently generated is as follows:

<?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:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" 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>https://hr.test.com/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://hr.test.com/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/" />
    </url>
    <url>
        <loc>https://hr.test.com/about/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://hr.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/about/" />
    </url>
</urlset>

But the correct format should be:

<?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:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" 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>https://hr.test.com/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://www.test.com/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/" />
    </url>
    <url>
        <loc>https://hr.test.com/about/</loc>
        <xhtml:link rel="alternate" hreflang="hr-HR" href="https://hr.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="en-US" href="https://www.test.com/about/" />
        <xhtml:link rel="alternate" hreflang="x-default" href="https://hr.test.com/about/" />
    </url>
</urlset>

@PabloGBarcelo
Copy link
Contributor

Something similar was happening on the i18n pages. I’ll take a look as soon as I’m free. Thanks for the example!

@harlan-zw
Copy link
Collaborator

In 5.3.1 the app sources and i18n.pages will respect the domains when generating the alternatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants