You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicate urls returned by generateRemixSitemap using React Router 7 #12
I do not know if its only related to RR7 or Remix v2 aswell, but when I use the following code to generate the sitemap, the generateRemixSitemap helper function returns duplicate links. Any chance to fix this or do you know why that is happening?
import{generateRemixSitemap}from"@forge42/seo-tools/remix/sitemap";importtype{Route}from"./+types/sitemap.xml";import{href}from"react-router";exportconstloader=async({ request }: Route.LoaderArgs)=>{const{ routes }=awaitimport("virtual:react-router/server-build");constsitemap=awaitgenerateRemixSitemap({domain: newURL(request.url).origin,ignore: [href("/api/chat"),href("/legal-notice"),href("/privacy-policy")],// @ts-expect-error Type mismatch, maybe related to a stricter type mentioned in release notes for v.7.0.0// https://github.com/forge-42/seo-tools/issues/8
routes,});returnnewResponse(sitemap,{headers: {"Content-Type": "application/xml",},});};
The reason behind this happening is that layout routes are also being mapped to the sitemap. In your example the routes/layout.tsx and routes/index.tsx will both generate a entry on the sitemap pointing to the home page of the website.
This can be fixed only showing routes that have a path or is they are the index of the layout (path !== undefined || index).
Activity
mateussilva92 commentedon Jan 6, 2026
The reason behind this happening is that layout routes are also being mapped to the sitemap. In your example the
routes/layout.tsxandroutes/index.tsxwill both generate a entry on the sitemap pointing to the home page of the website.This can be fixed only showing routes that have a path or is they are the index of the layout (
path !== undefined || index).I'll be creating a PR to address the issue.