Urgent.News

What's breaking now, across thousands of outlets.

Tech

Find Broken Pages on Your Site From Its Sitemap, With One Python File

After a migration or redesign, the sitemap often keeps listing URLs that now return a 404, or that bounce through a redirect. Search engines notice before you do, and so do visitors. Online link checkers work, but many cap the page count, want an account, or can't be scripted. I wanted something I could run from a terminal or a cron job and trust to fail loudly. So I wrote a Hermes skill,…

After a website migration or redesign, an outdated sitemap may still include URLs that no longer exist or redirect visitors elsewhere. Search engine crawlers detect these broken links before they become apparent to site owners and their users. While online link checker tools are available, many impose limits on the number of pages they can test, require account registration, or cannot be automated.

The reporter sought a simple solution they could run in a terminal or as part of a scheduled job to catch these issues without delay. Thus, they created a Python script called sitemap-link-checker within the Hermes skill framework. This script reads a sitemap file in plain text, gzip format, or as an index of multiple sitemaps, and sends a HEAD request to each listed URL.

If a server refuses the HEAD request, it automatically switches to a GET request. The script then reports any broken URLs and redirects found during the scan. With the additional --links flag, it goes a step further by opening each webpage and examining its outbound links, noting which page each dead link was discovered on. The reporter executed the script using the command "python3 scripts/sitemap_check.py https://example.com/sitemap.xml --links --max-urls 50," which successfully identified 1 broken page (404 error) and 1 redirected URL (301 redirect) out of the 3 sitemap URLs tested.

The script exits with a status code of 1 if any broken links are detected, making it easy to incorporate into automated job scheduling. A local server test feature called --selftest is included, which sets up a test environment with a 404 error page, a redirect, and a dead link to ensure the checker properly identifies all three types of issues.

However, the tool has some limitations: it can only detect broken links listed in the provided sitemap, does not follow JavaScript-rendered links, and some websites may reject script-based requests by returning a 403 error. To run the checker, one must have permission to test the website as the tool will not function on sites they are not authorized to access.

The sitemap-link-checker script is released under the MIT open-source license in the Hermes-skills GitHub repository, allowing anyone to freely use, modify, and distribute the tool.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Deprecate a Go Function and Let go fix Migrate Every Caller With //go:fix inline

Book: The Complete Guide to Go Programming Also by me: Pocket Guides for Developers — the 8-book series My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI…

  • Go 1.26 introduces go fix to automate deprecated API updates
  • //go:fix inline directive updates call sites to new API
  • money package's FormatCents replaced with Format function

Late payment email templates: what to send on day 3, 7, 14 and 30

Drafted by an AI agent for Kindly Remit, a small shop of plain-English paperwork for freelancers who are still waiting to be paid. The invoice went out on the 1st. It was due on the 14th.

  • Day 3 email serves as gentle reminder before due date
  • Day 7 email asks about payment delays and offers help
  • Day 14 email requests specific payment date if overdue

The ss Command Is More Powerful Than You Think: 10 Practical Examples

Modern socket diagnostics, TCP queue inspection, and kernel-level network troubleshooting for Linux engineers If you still type netstat -tulpn during a late-night production outage, you are leaning on…

  • ss command offers faster, less CPU-intensive socket diagnostics than netstat.
  • ss accesses Linux kernel directly via Netlink sockets for real-time visibility.

More from Sunday 1 November →