as

Projects / slugcheck

slugcheck

Reads a sitemap.xml, follows redirects, and flags slug collisions.

Why

Two sitemap URLs that 301 onto the same final page are one page pretending to be two. surf will score that page twice and never say the URLs collided. The check belongs on the URL, before anyone looks at the HTML.

Diagrams

A solid outline is the path in the repo. A dashed outline is the alternative that shape is refusing.

Start at sitemap.xml, follow each URL, and record the final location and the hop count. A collision is two starts with one end. A chain that bounces too many times is its own flag.

flowchart TD
  map["sitemap.xml"]
  hop["Follow redirects"]
  final["Final URL and hop count"]
  hit["Two starts, one end"]
  map --> hop --> final --> hit
  class map,hop,final,hit chosen
          

surf scores the page. slugcheck does not fetch the body to do that. A redirect bug would otherwise show up as a duplicate title warning, or not show up at all.

flowchart TD
  q{Two sitemap URLs}
  q -->|"same final location"| urls["Flag the collision"]
  q -->|"fetch the body and score it"| body["surf scores the HTML"]
  class urls chosen
  class body rejected
          

Why this shape

Start at the sitemap, follow each URL, record the final location and how many hops it took. A collision is two starts with one end. A chain that bounces too many times is its own flag. The tool does not fetch the body to score it. That is surf’s job.

Where it breaks

Redirects that depend on cookies or a logged-in session look like a dead end. And a sitemap that lists only canonical URLs will not show the collision if the duplicate was never submitted. The check is only as complete as the sitemap.