Skip to content

Old JavaScript docs links go to the utility they pointed at - #13

Merged
hyanmandian merged 2 commits into
mainfrom
seo/legacy-ids
Oct 13, 2026
Merged

hyanmandian merged 2 commits into
mainfrom
seo/legacy-ids

Conversation

@hyanmandian

@hyanmandian hyanmandian commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Search Console lists 137 old docsify URLs (/utilities?id=isvalidcpf, /pt-br/utilities?id=cep-e-endereço, ...) as alternates of the JavaScript library's page: _redirects cannot read a query string, so they all land there.

  • /legacy-ids.json (static): old anchor → utility page and section, per language. Built from the JavaScript symbols in the validator's status, the utilities' titles and ids, and the old page's other headings (a fixed list).
  • public/_worker.js (Cloudflare Pages advanced mode) answers those URLs with a 301 to the utility, in one hop. _routes.json limits it to /utilities, /pt-br/utilities and the JavaScript library's pages; everything else stays a static file. No script on any page.

Checked with wrangler pages dev on the build:

Request Response
/utilities?id=isvalidcpf 301 → /utils/cpf/#validate
/pt-br/utilities?id=cep-e-endereço 301 → /pt-br/utils/cep/
/pt-br/utilities/?id=getcid10 301 → /pt-br/utils/cid10/#consultar
/libs/javascript/?id=formatCNPJ 301 → /utils/cnpj/#format
/utilities?id=standard-schema (no utility) 301 → /libs/javascript/?id=standard-schema, then 200
/utilities, /pt-br/utilities/ 301 → the library's page, as before
/libs/javascript/, /utils/cpf/, / 200, headers from _headers
/guides/schema 301 from _redirects, as before

Every one of the 616 targets (page and anchor, both languages) exists in the build; 111 of the 125 ids in Search Console's sample map.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RaUEDkvXY8rVWTJG2GKfhu

The docsify site kept the section in the query string (/utilities?id=isvalidcpf,
/pt-br/utilities?id=cep-e-endereço). _redirects sends those to the JavaScript
library's page with the ?id= kept, and Google counted 137 of them as alternates of
that one page. The library's page now reads the id and replaces the location with
the utility's page (and the function's section), from /legacy-ids.json: the
JavaScript symbols from the last validator run, the utilities' titles and ids, and
the old page's other section headings. An unknown id stays on the library's page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RaUEDkvXY8rVWTJG2GKfhu
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Preview: https://pr-13.brazilian-utils-docs.pages.dev (236abba)

public/_worker.js answers the old URLs with a 301 to the utility's page, from
/legacy-ids.json. _routes.json limits it to /utilities, /pt-br/utilities and the
JavaScript library's pages: every other request stays a static file. The
library's page no longer carries a script, and a crawler gets a real redirect
in one hop (/utilities?id=isvalidcpf → /utils/cpf/#validate) instead of two
plus a JavaScript one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RaUEDkvXY8rVWTJG2GKfhu
@hyanmandian
hyanmandian merged commit d543122 into main Oct 13, 2026
2 checks passed
@hyanmandian
hyanmandian deleted the seo/legacy-ids branch October 13, 2026 22:25
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.

1 participant