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

The generated site map does not have xml tag #141

Closed
hiphop101 opened this issue Jun 22, 2020 · 8 comments
Closed

The generated site map does not have xml tag #141

hiphop101 opened this issue Jun 22, 2020 · 8 comments

Comments

@hiphop101
Copy link

The generated XML does not have xml tag. Google search console does not recognize it.

is missing
@NicoPennec
Copy link
Member

Hi @hiphop101

Please give more details to reproduce your issue.

@hiphop101
Copy link
Author

Hi Nico,

if you notice that the sitemap generated does not have

<?xml version="1.0" encoding="UTF-8"?>

@NicoPennec
Copy link
Member

NicoPennec commented Jun 22, 2020

without details about your config and the nuxt mode (spa? generate?) I cannot reproduce...

Please at least share your nuxt version, your sitemap module version and your nuxt config.

@hiphop101
Copy link
Author

hiphop101 commented Jun 22, 2020

Sure.
here are my package.json
should all be latest as I created this project last weekend.

"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .",
"lint": "yarn lint:js"
},
"dependencies": {
"@nuxt/content": "^1.3.2",
"@nuxtjs/axios": "^5.11.0",
"@nuxtjs/sitemap": "^2.3.2",
"apexcharts": "^3.19.2",
"d3": "^5.16.0",
"nuxt": "^2.13.0",
"nuxt-buefy": "^0.3.31"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^3.0.0",
"@nuxtjs/eslint-module": "^2.0.0",
"@nuxtjs/google-analytics": "^2.3.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-nuxt": "^1.0.0",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.0.5"
}

@NicoPennec
Copy link
Member

I need your sitemap config from your nuxt.config.js file

@hiphop101
Copy link
Author

hiphop101 commented Jun 22, 2020

here it is:

sitemap: { hostname: 'my website URL', gzip: true, path: '/sitemap.xml', xmlNs: 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' }

@NicoPennec
Copy link
Member

Your config seems good on sitemap part. Maybe the sitemap is not well declare in "modules" part. Maybe you call a wrong URL according other nuxt config (eg. with a base url). Create a github repository to share a use case that reproduce your issue.

Without all details to reproduce your issue, I will not help your any more more. Sorry.

@urbgimtam
Copy link

urbgimtam commented Jun 7, 2022

I've also got bitten by this bug today.

For what I understand, it only happens when the sitemap is using i18n or when you're injecting a links object for each route.
Because this will generate the tag <xhtml:link rel="alternate" hreflang="xx" href="https://example.com/xx" />

When the xhtml:link tag is generated, the resulting sitemap ends up missing the xml version tag
<?xml version="1.0" encoding="UTF-8"?>

The output becomes this:

<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:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
  <url>
    <loc>https://example.com/pt</loc>
    <lastmod>2022-06-07T17:11:37.986Z</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
    <xhtml:link rel="alternate" hreflang="pt" href="https://example.com/pt" />
  </url>
  <url>
    <loc>https://example.com/en</loc>
    <lastmod>2022-06-07T17:11:37.986Z</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
    <xhtml:link rel="alternate" hreflang="pt" href="https://example.com/pt" />
  </url>
</urlset>

when it should have been like this:

<?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:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
  <url>
    <loc>https://example.com/pt</loc>
    <lastmod>2022-06-07T17:11:37.986Z</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
    <xhtml:link rel="alternate" hreflang="pt" href="https://example.com/pt" />
  </url>
  <url>
    <loc>https://example.com/en</loc>
    <lastmod>2022-06-07T17:11:37.986Z</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en" />
    <xhtml:link rel="alternate" hreflang="pt" href="https://example.com/pt" />
  </url>
</urlset>

After a bit of digging, it seems the bug comes from the sitemap.js library itself.
At least, its what this issue makes me think.

If possible, please reopen the issue.

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