Repository navigation
feat: page tags, link previews and sitemap for SEO - #4318
Conversation
mesudip
left a comment
There was a problem hiding this comment.
The parts I checked look right:
- the escaping of user text into HTML, attributes and JSON-LD (
src/seo/text.ts,render.ts), and the input caps and linear patterns; - the card renderer's limits;
- the forum client never holding up a page load;
- do-not-list DReps kept out of the sitemap;
- nginx dropping the gateway's headers before calling the backend.
Backend npm run verify (30 suites, 636 tests) and the frontend's tsc, lint and vitest pass. Two nginx problems need fixing. I reproduced both by running this PR's nginx.conf and docker-entrypoint.sh in the stock nginx 1.30.6 image, with the brotli directives removed because that image lacks the module.
Must fix
-
Open redirect off gov.tools.
- The rule is
govtool/frontend/nginx.conf:33:location ~* ^/connected(/.+)$ { return 301 $1$is_args$args; }, withabsolute_redirect off. GET /connected/%5Cevil.exampleanswers301 Location: /\evil.example.GET /connected/%09/evil.exampleanswers301 Location: /<TAB>/evil.example.- The URL standard treats
\as/in http(s) and strips tabs, so browsers resolve both tohttps://evil.example/. That makes any gov.tools link usable for phishing. - The other redirect rules put a fixed segment first and stay on-site.
- Fix: either drop the server-side
/connectedrule (the app'sgetCurrentUrlalready rewrites it), or constrain the capture, e.g.^/connected(/[A-Za-z0-9_-][^\\\s]*)$. Add both payloads toscripts/check-seo-nginx.sh.
- The rule is
-
SEO_NOINDEXdoesn't reach every response.- An
add_headerinside a location turns off the server-leveladd_headers there. - With
SEO_NOINDEX=true, the/og/cards and/budget-proposals-2025/*.jsonare served withoutX-Robots-Tag(as ismaintenance.json), so a test site's cards can be indexed. govtool/frontend/AGENTS.md:103says "everywhere", andcheck-seo-nginx.sh:167-168checks only/and/robots.txt.docs/nginx.conf.template:5-7documents exactly this trap.- Fix: send the header in those locations too, e.g. from a variable the entrypoint sets, and test
/og/.
- An
Should fix
-
Orphaned doc comment. In
src/drep/drep.service.ts:163-172the new methods were inserted betweenwithStoredProfile's doc comment and the method. That comment now sits abovestoredSeoDRep's, andwithStoredProfilehas none. -
Decision log. This D178 clashes with #4320's D178, so whichever merges second renumbers. It is also dated 2026-11-17, below D177 (2026-11-20), in a log kept newest-last.
-
Stacked on #4317. The first commit here is #4317's (e1ca0e2). Please say so in the description, and merge #4317 first.
Worth considering
-
Unknown paths get the noindex defaults (
src/seo/pages.ts,defaults()). #4316 adds a public/activitypage, which will need a row insrc/seo/routes.ts. -
SEO_NOINDEXdefaults to indexable (SEO_NOINDEX=${SEO_NOINDEX:-}in the Swarm stack), so every test site has to remember to set it. A default of noindex, with production opting in, fails safe. -
About 9.2 MB of Noto Sans JP OTF goes into git and the backend image; a subset would be enough.
|
1. Open redirect. Fixed in 53d313a. The server-side 2. 3. Doc comment. Fixed in b86b2ce. 4. Decision log. Renumbered to D180 (#4320 has D178, #4322 D179) and dated 2026-12-02, in b86b2ce. 5. Stacking. #4317 is merged, so this PR's diff is now only its own commits. 6. Unknown paths. Deliberate: an unknown path gets 7. 8. Noto Sans JP size. Done, see the comment below. |
5131f7f to
b86b2ce
Compare
|
8. Noto Sans JP size. Subset to Latin, Greek, Cyrillic, kana, CJK symbols and JIS X 0208's non-kanji rows and level-1 kanji: 9.2 MB down to 2.3 MB for both weights, and about 135 MB less resident memory once the fonts load. A level-2 kanji now gets the default card through the existing cmap check, never boxes. The subset replaces the fonts in the original backend commit, so the 9 MB files never reach develop's history. The branch was force-pushed for that; the commit IDs in my comment above are updated. |
List of changes
/seoroutes write them and the frontend's nginx includes them inindex.html(SSI, 500 ms timeout, site-wide defaults on any failure)sitemap.xmlandrobots.txtSEO_BACKEND_URL,SITE_URL,SEO_NOINDEX(frontend) andGOVTOOL_SITE_URL,GOVTOOL_SEO_URL_SCHEME(backend). SetSEO_NOINDEX=trueon every site except gov.toolsChecklist