Duplicate urls returned by `generateRemixSitemap` using React Router 7

Open
#12 1 comment 4 reactions 0 assignees View on GitHub

@mateussilva92 is already working on this.

Since Jan 6, 2026.

  • #20 by @mateussilva92 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
backend, web-dev

Research direction

Start at the generateRemixSitemap call in the provided loader and compare the routes from virtual:react-router/server-build with the routes.ts configuration. Reproduce the generated XML with the shown React Router 7 setup, trace where duplicate paths enter the helper, and verify that each sitemap URL appears only once.

Written by the indexing model from the issue text.

Description

Hi @AlemTuzlak, first of thanks for the package!

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";
import type { Route } from "./+types/sitemap.xml";
import { href } from "react-router";

export const loader = async ({ request }: Route.LoaderArgs) => {
  const { routes } = await import("virtual:react-router/server-build");
  const sitemap = await generateRemixSitemap({
    domain: new URL(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,
  });

  return new Response(sitemap, {
    headers: {
      "Content-Type": "application/xml",
    },
  });
};
// routes.ts
import {
  type RouteConfig,
  index,
  layout,
  prefix,
  route,
} from "@react-router/dev/routes";

export default [
  layout("routes/layout.tsx", [
    index("routes/index.tsx"),
    ...
    route("sitemap.xml", "routes/sitemap.xml.ts"),
    route("robots.txt", "routes/robots.txt.ts"),
  ]),
] satisfies RouteConfig;

The generated sitemap:

<url>
  <loc>http://localhost:5173/</loc>
</url>
<url>
  <loc>http://localhost:5173/</loc>
</url>
<url>
  <loc>http://localhost:5173/chat</loc>
</url>
<url>
  <loc>http://localhost:5173/blog</loc>
</url>
<url>
  <loc>http://localhost:5173/</loc>
</url>
Dominant language
TypeScript
Stars
96
Forks
9
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from code-forge-io/seo-tools

All issues in code-forge-io/seo-tools

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.