Repository navigation
feat(seo): add sitemap, robots.txt, canonical and hreflang links - #10
Merged
Merged
Conversation
Google had no sitemap to read and could reach the Chinese pages only through the JavaScript language selector. - Generate sitemap.xml listing every English and Chinese page with hreflang alternates, and robots.txt pointing to it - Give every page a canonical link and en / zh-CN / x-default hreflang links - Add a plain footer link to the page in the other language so crawlers can follow it - Check all of the above in check-frontend.js, and document it in docs/frontend.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
codesheet.io doesn't show up on Google yet. The site went live on 2026-11-25, so mostly it's too new. But the site also made crawling harder than it needed to be:
/sitemap.xmland/robots.txtreturned 404, so Google could find pages only by following links.<select>. No<a>in the HTML pointed to them.canonicalorhreflanglinks, so the English and Chinese versions weren't marked as translations of each other.What changed
src/pages/sitemap.xml.jsgeneratessitemap.xmlwith all 22 pages (en + zh). Each entry listsen,zh-CNandx-defaulthreflang alternates.src/pages/robots.txt.jsallows all crawlers and points to the sitemap's absolute URL.Layout.astrogives every page acanonical(same URL asog:url), plusen/zh-CN/x-defaulthreflang links.<a>to the same page in the other language ("简体中文" / "English"). Links now wrap on narrow screens.langPaths()insrc/lib/paths.jsmaps/cpp/↔/zh/cpp/. URLs are still built withsite+base, so github.io forks keep working.scripts/check-frontend.jsCheck 9 fails the build when any of the following is wrong:canonicalisn't its own URL or doesn't matchog:urlrobots.txtdoesn't point to the sitemapdocs/frontend.mddocuments the above.Verification
npm run build && npm run checkpasses: 22 pages have canonical and hreflang links, and the sitemap lists all 22.SITE_URL=https://kepler2024.github.io BASE_PATH=/Codesheet) passes too. The canonical, sitemap and robots URLs all sit under/Codesheet/.<loc>from the built sitemap, the check fails withdist/sitemap.xml does not list dist/zh/rust/index.html.After merge
Verify codesheet.io in Google Search Console, submit
https://codesheet.io/sitemap.xml, and request indexing of the homepage.🤖 Generated with Claude Code