Improve SEO: rich bill metadata, sitemap, robots, JSON-LD - #74
Open
mikaalnaik wants to merge 2 commits into
Open
Improve SEO: rich bill metadata, sitemap, robots, JSON-LD#74mikaalnaik wants to merge 2 commits into
mikaalnaik wants to merge 2 commits into
Conversation
- Bill pages now use real titles ("C-11: <name>") and meta descriptions
derived from the bill summary, plus keywords from genres; not-found bills
return noindex
- Memoize the bill resolver (React cache) so generateMetadata and the page
share a single fetch (src/server/get-unified-bill.ts)
- Add dynamic sitemap.ts listing home + all bills with canonical URLs
- Replace static robots.txt (wrong sitemap target) with robots.ts pointing at
the app's own sitemap and disallowing non-public routes
- Add schema.org JSON-LD: Legislation + BreadcrumbList on bill pages,
WebSite on home (src/components/JsonLd.tsx)
- Add src/utils/seo.ts (getCanonicalOrigin, stripMarkdown, truncate) for a
single deterministic canonical origin; set metadataBase fallback
- Extract shared bill-merge logic to src/server/get-merged-bills.ts
- Remove redundant hand-rolled twitter:* meta tags
Co-Authored-By: Claude Opus 4.8 <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.
Context
The bills app had solid baseline metadata (per-page OG/Twitter tags, dynamic OG images) but several gaps limited search visibility: bill pages had generic titles/descriptions, there was no sitemap, and the static
robots.txtpointed at the wrong app's sitemap. This PR is a full SEO pass.Changes
Content metadata
C-11: Military Justice System Modernization Act · Builder MP) and meta descriptions derived from the real AI summary (markdown-stripped, truncated to ~155 chars), pluskeywordsfrom genres.robots: noindex,nofollow.cache()(src/server/get-unified-bill.ts) sogenerateMetadataand the page component share a single fetch.Discoverability
src/app/sitemap.tslists home + every bill withlastModified, using absolute canonical URLs. Wrapped in try/catch so a data outage can't 500 it.robots.txt(which referenced the wrong app's sitemap) withsrc/app/robots.tspointing at the app's own sitemap and disallowing non-public routes.src/server/get-merged-bills.ts(used by home + sitemap).Structured data
src/components/JsonLd.tsxhelper. Bill pages emit schema.orgLegislation+BreadcrumbList; home emitsWebSite.Hygiene
src/utils/seo.ts(getCanonicalOrigin,stripMarkdown,truncate) for a single deterministic canonical origin (https://www.buildcanada.com); setmetadataBasefallback.twitter:*meta tags across layout/home/bill pages.Verification
tsc --noEmitclean;biome checkclean; unit tests pass (pre-commit hook)./bills/robots.txtand/bills/sitemap.xmlrender with canonicalhttps://www.buildcanada.com/bills/...URLs.twitter:card, 2 JSON-LD blocks.<meta name="robots" content="noindex">.WebSiteJSON-LD.Deployment note
Because the app runs under the
/billsbasePath, itsrobots.txt/sitemap.xmlare served at/bills/.... Crawlers honor robots.txt only at the host root, so the rootbuildcanada.com/robots.txtshould referencehttps://www.buildcanada.com/bills/sitemap.xml(or submit the sitemap directly in Search Console).🤖 Generated with Claude Code