How to prevent trailing slash being added to the paths in additionalPaths
See original GitHub issueDescribe the bug A trailing slash is being added to the paths in additionalPaths. I previously created a bug report but it was closed, assuming it was fixed, I tried with the latest version but still experience the same behaviour so recreating the issue again.
To Reproduce Steps to reproduce the behavior:
- Update
next-sitemap.js
:
module.exports = {
siteUrl: 'https://example.com',
generateRobotsTxt: true,
additionalPaths: async (config) => [
await config.transform(config, '/additional-page.html'),
],
};
- Build and export next app
- Result:
<url><loc>https://example.com/additional-page.html/</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-10-15T07:05:21.440Z</lastmod></url>
Expected behavior
It shouldn’t include trailing slash if not needed - <loc>https://example.com/additional-page.html</loc>
. When crawlers access the page with trailing slash (e.g. https://example.com/additional-page.html/
), the page will break because of the assets it requires. It should be accessed by crawlers without the trailing slash.
Additional context
I’m using next-sitemap@1.8.4
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to get path without trailing slash or backslash
The following solution works: path = path.strip(r'\/').
Read more >path.relative adds trailing slash in node 12 #28549 - GitHub
In node 12 we now get a trailing slash. What I expect should happen. We either resolve all paths with or without trailing...
Read more >gatsby-plugin-force-trailing-slashes
A web-server that treats trailing-slash paths as directories with an index.html inside and non-trailing-slash paths as named documents (and ideally redirects ...
Read more >Trailing slash in file path results in file not found
Removing the slash fixes it and the folder is found. ... The path in Git is different from the path in windows, you...
Read more >Edit paths in Adobe Photoshop
Adjust path segments. You can edit a path segment at any time, but editing existing segments is slightly different from drawing them. Keep...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dominicarrojado @mordgard Fixed #310
@iamvishnusankar I’m afraid it is still not fixed: https://codesandbox.io/s/interesting-tu-toztvx?file=/next.config.js
When there’s
next.config.js
with thetrailingSlash: true
. thenext-sitemap.js
config does not override it.