Skip to content

Add fix-geo-links.sh server script for GEO link URLs#692

Open
fredericsimard wants to merge 2 commits into
mainfrom
fix/geo-links-server-script/2026-07-21
Open

Add fix-geo-links.sh server script for GEO link URLs#692
fredericsimard wants to merge 2 commits into
mainfrom
fix/geo-links-server-script/2026-07-21

Conversation

@fredericsimard

@fredericsimard fredericsimard commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add scripts/fix-geo-links.sh, a server-side script that rewrites the <link rel="alternate" type="text/markdown"> GEO (Generative Engine Optimization) tag on every built page — this tag points AI bots/crawlers at the page's raw Markdown source, built from each config/<lang>/mkdocs.yml's repo_url. That's still set to the old google/transit repo (kept intentionally for the "Edit this page" link and GitHub icon), but docs/<lang>/ content now actually lives in MobilityData/gtfs.org, so the generated raw-content URL 404s for bots. This script rewrites just that URL across the built HTML.
  • Added an OS check so sed -i works on both the Ubuntu server (GNU sed) and macOS (BSD sed) for local testing, without changing the command that actually runs on Ubuntu at all.

Why

AI/LLM crawlers following the GEO markdown-alternate link were hitting a 404 against the stale google/transit raw URL instead of reaching the real page source in MobilityData/gtfs.org.

Test plan

  • Built the English site locally and confirmed 108/127 generated HTML files contain the text/markdown alternate link
  • Ran the script against a copy of the build output and confirmed all occurrences of the old URL were replaced with the new one, with no remaining old-URL matches
  • Verified the macOS code path (BSD sed) produces the same result as the Ubuntu code path (GNU sed) would
  • Run on the production server against the real deployed site directory

Every built page ships a <link rel="alternate" type="text/markdown">
tag pointing AI bots at the page's raw Markdown source, built from
each config/<lang>/mkdocs.yml's repo_url. That's still set to the old
google/transit repo (kept for the "Edit this page" link and GitHub
icon), but docs/<lang>/ now lives in MobilityData/gtfs.org, so the
generated raw-content URL 404s. This script rewrites that URL across
the built HTML so bots can actually fetch the source.

Corrected the header comment/description, which was copy-pasted from
remove-subscribe-banner.sh and described the wrong script entirely,
dropped an unused leftover variable from that same copy-paste, and
added an OS check so the sed in-place edit works on both the Ubuntu
server (GNU sed) and macOS (BSD sed) without changing the Ubuntu
command at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a server-side post-processing script to rewrite the built pages’ link[rel="alternate"][type="text/markdown"] raw-Markdown URL base from google/transit to MobilityData/gtfs.org, preserving existing MkDocs repo_url usage for “Edit this page” while ensuring GEO crawlers don’t hit 404s.

Changes:

  • Added scripts/fix-geo-links.sh to replace the old raw GitHub base URL across generated .html files.
  • Included a macOS vs Linux sed -i compatibility branch for local testing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/fix-geo-links.sh Outdated
OLD_BASE was used unescaped as the sed search pattern, so the literal
"." in github.com was interpreted as "match any character" instead of
a literal dot, loosening the match more than intended.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants