A privacy-friendly help widget that answers visitor questions from the site's own content and links to the full page — runs 100% in the browser, no API, no server, no per-token cost. - tools/build_search_index.py: parses every EN/MK/SI page into ~720 heading-level chunks per language -> assistant/index-<lang>.json (lazy-loaded only when the chat is opened; gzips to ~80 KB). - assistant.js: dependency-free BM25 search + multilingual stopword filtering + a curated short-answer layer for common questions, plus an accessible chat widget (role=dialog, keyboard, aria). CSP-safe (self only). - assistant.css: scoped .msa-* styles in the site's teal palette; responsive (full-screen panel on mobile). - Injected on 208 pages (blog WIP excluded; picks it up when that lands). Verified in a headless browser across EN/MK/SI: curated answers, search fallback with correct ranking (rare terms win), correct deep links, Cyrillic + Slovene diacritics, and zero console errors. Curated MK/SI answers are machine-drafted — proofread before launch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| README.md | ||
| build_search_index.py | ||
| seo_inject.py | ||
README.md
tools/
seo_inject.py
Injects a technical-SEO block into every language page (en|mk|si/**/index.html)
and regenerates sitemap.xml + robots.txt. Safe to re-run — the block lives
between <!-- SEO:START --> and <!-- SEO:END --> and is replaced in place.
The block adds: meta description (auto-extracted from the page's lead/subtitle
where available), canonical, hreflang alternates (en / mk / sl / x-default),
Open Graph, Twitter Card, and an Organization JSON-LD.
All absolute URLs point at the final domain https://msosorg.com (not the
temporary host), so nothing needs rewriting at launch. Note: the Slovene folder
is /si/ but the ISO code is sl — the script maps si → sl for hreflang/locale.
Usage
python tools/seo_inject.py # dry run: print the block for pilot pages
python tools/seo_inject.py --all # write the block into every page
python tools/seo_inject.py --all --sitemap # also rebuild sitemap.xml + robots.txt
Run --all --sitemap after adding, renaming, or deleting any page so canonical
tags, hreflang alternates, and the sitemap stay in sync.