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

Same route added multiple times in the sitemap.xml #3

Closed
Skyost opened this issue Jan 5, 2023 · 2 comments
Closed

Same route added multiple times in the sitemap.xml #3

Skyost opened this issue Jan 5, 2023 · 2 comments

Comments

@Skyost
Copy link

Skyost commented Jan 5, 2023

Describe the bug

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

Reproduction

No response

System Info

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.
@harlan-zw
Copy link
Collaborator

Hey @Skyost

Thanks for the issue. I've pushed up a workaround to avoid duplicate entries, available in v0.5.8.

You may have run into this because you have links to the same routes which have both trailing and non-trailing slashes. You may want to check your links as you'll be pre-rendering both currently, as far as I understand it. If you use https://github.com/harlan-zw/nuxt-link-checker, it will warn you.

@Skyost
Copy link
Author

Skyost commented Jan 6, 2023

Hey @harlan-zw,

Thanks for the tip and for the fix ! In fact, I saw your package before, I just wasn't sure whether I needed it. I will definitely give it a try.

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

2 participants