diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index cf57c1a..92f9a71 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -76,6 +76,7 @@ jobs: kern/ \ technology/ \ references/ \ + company/ \ includes/nav.html \ includes/footer.html @@ -93,13 +94,16 @@ jobs: echo "::error file=$file::Missing meta description" missing=$((missing + 1)) fi - done < <(find index.html kern/ technology/ references/ -name "*.html") + done < <(find index.html kern/ technology/ references/ \ + company/about-us.html company/career.html \ + company/get-in-touch.html company/media.html company/news.html \ + -name "*.html" 2>/dev/null) if [ "$missing" -gt 0 ]; then echo "::error::$missing page(s) missing " exit 1 fi - echo "All KERN pages have meta descriptions ✓" + echo "All pages have meta descriptions ✓" # ── 6. Image size budget ──────────────────────────────────────────────────── images: diff --git a/build.py b/build.py index 9f114ad..5734c9e 100644 --- a/build.py +++ b/build.py @@ -24,6 +24,7 @@ ROOT = Path(__file__).parent TEMPLATES_DIR = ROOT / "templates" LOCALES_DIR = ROOT / "locales" +BASE_URL = "https://riddleandcode.com" # Maps language code → output directory LANGS = { @@ -32,6 +33,56 @@ } +def get_canonical_url(tmpl_path: Path) -> str | None: + """Return the canonical EN URL for a template, or None for partials.""" + rel = str(tmpl_path.relative_to(TEMPLATES_DIR)).replace("\\", "/") + if rel.startswith("includes/"): + return None + if rel == "index.html": + return f"{BASE_URL}/" + if rel.endswith("/index.html"): + return f"{BASE_URL}/{rel[:-len('index.html')]}" + return f"{BASE_URL}/{rel}" + + +def build_sitemap() -> None: + """Generate sitemap.xml with bilingual hreflang annotations.""" + templates = sorted(TEMPLATES_DIR.rglob("*.html")) + entries = [] + for tmpl_path in templates: + en_url = get_canonical_url(tmpl_path) + if en_url is None: + continue + rel = str(tmpl_path.relative_to(TEMPLATES_DIR)).replace("\\", "/") + if rel == "index.html": + de_url = f"{BASE_URL}/de/" + elif rel.endswith("/index.html"): + de_url = f"{BASE_URL}/de/{rel[:-len('index.html')]}" + else: + de_url = f"{BASE_URL}/de/{rel}" + + for loc in (en_url, de_url): + entries.append( + f" \n" + f" {loc}\n" + f" \n" + f" \n" + f" \n" + f" " + ) + + xml = ( + '\n' + '\n' + + "\n".join(entries) + + "\n\n" + ) + out = ROOT / "sitemap.xml" + out.write_text(xml, encoding="utf-8") + print(f" [sitemap] → sitemap.xml ({len(entries)} URLs)") + + def render(template: str, strings: dict) -> str: """Replace {{ key }} placeholders with values from strings dict.""" def replace(m): @@ -73,7 +124,8 @@ def build() -> int: source = tmpl_path.read_text(encoding="utf-8") for lang, out_dir in LANGS.items(): - strings = {**locales[lang], "lang": lang} + canonical = get_canonical_url(tmpl_path) + strings = {**locales[lang], "lang": lang, "canonical_url": canonical or ""} rendered = render(source, strings) out_path = out_dir / rel @@ -83,6 +135,7 @@ def build() -> int: print(f" [{lang}] {rel} → {out_path.relative_to(ROOT)}") built += 1 + build_sitemap() return built @@ -97,7 +150,8 @@ def check_mode(): source = tmpl_path.read_text(encoding="utf-8") for lang, real_dir in LANGS.items(): - strings = {**locales[lang], "lang": lang} + canonical = get_canonical_url(tmpl_path) + strings = {**locales[lang], "lang": lang, "canonical_url": canonical or ""} rendered = render(source, strings) real_file = real_dir / rel diff --git a/company/about-us.html b/company/about-us.html index b1da564..a7aaed7 100644 --- a/company/about-us.html +++ b/company/about-us.html @@ -7,11 +7,13 @@ + + diff --git a/company/career.html b/company/career.html index 4b7c9c2..2ce0a03 100644 --- a/company/career.html +++ b/company/career.html @@ -7,11 +7,13 @@ + + diff --git a/company/get-in-touch.html b/company/get-in-touch.html index e5b1a0e..289cea4 100644 --- a/company/get-in-touch.html +++ b/company/get-in-touch.html @@ -7,11 +7,13 @@ + + diff --git a/company/media.html b/company/media.html index 48940ae..18b1a8a 100644 --- a/company/media.html +++ b/company/media.html @@ -7,11 +7,13 @@ + + diff --git a/company/news.html b/company/news.html index d399b64..bb1d3fe 100644 --- a/company/news.html +++ b/company/news.html @@ -7,11 +7,13 @@ + +