Skip to content

Repository files navigation

riddleandcode.com — Static Site

Bilingual static site for riddleandcode.com. Pages are generated from templates and locale files by a Python build script.

Prerequisites

Python 3.8+ and PyYAML:

pip install -r requirements.txt

Building

python3 build.py

This reads every file under templates/ and renders it twice — once in English (output to the repo root) and once in German (output to de/).

Example:

templates/kern/for-utilities.html → kern/for-utilities.html (EN)
→ de/kern/for-utilities.html (DE)
templates/includes/nav.html → includes/nav.html (EN)
→ de/includes/nav.html (DE)

Currently produces 30 files across both languages.

How it works

Templates (templates/)

HTML files with {{ key }} placeholders. The build substitutes every placeholder with the value from the active locale file.

<h1>{{ ku_h1 }}</h1><pclass="lead">{{ ku_lead }}</p>

<pre> blocks (ASCII diagrams, code loops) are kept as static content and not templated, to avoid YAML escaping complexity.

Locale files (locales/)

FileLanguage
locales/en.yamlEnglish
locales/de.yamlGerman

Keys are grouped by page using a prefix convention:

PrefixPage
shared_Strings reused across pages
nav_Navigation bar
footer_Footer
ki_kern/index.html
ku_kern/for-utilities.html
ka_kern/for-aggregators.html
kc_kern/for-communities.html
kp_kern/for-platforms.html
rp_references/index.html
tech_technology/index.html
au_company/about-us.html
git_company/get-in-touch.html
med_company/media.html
car_company/career.html
news_company/news.html

Navigation prefix (nav_prefix)

Internal links in nav and footer templates use {{ nav_prefix }}:

<ahref="{{ nav_prefix }}kern/">{{ nav_products }}</a>
LocaleValueResulting link
en.yaml"/"/kern/
de.yaml"/de/"/de/kern/

Runtime component loading (scripts/main.js)

The nav and footer are loaded at runtime via fetch(). main.js detects whether the current URL starts with /de/ and loads the correct include:

  • EN pages → includes/nav.html, includes/footer.html
  • DE pages → de/includes/nav.html, de/includes/footer.html

Adding a new page

  1. Create templates/<section>/page.html with {{ key }} placeholders.
  2. Add the corresponding keys to both locales/en.yaml and locales/de.yaml.
  3. Run python3 build.py.

Checking for stale builds (CI)

python3 build.py --check

Renders into a temp directory and diffs against the working tree. Exits non-zero if any generated file is out of date. Used by the GitHub Actions build-fresh job.

Serving locally

Any static file server works. For example:

python3 -m http.server 8089

Then open http://localhost:8089.

Directory structure

templates/ Source templates (edit these, not the output)
includes/ nav.html, footer.html
index.html
kern/
company/
references/
technology/
locales/
en.yaml English strings
de.yaml German strings
build.py Build script
requirements.txt Python dependencies (pyyaml)
scripts/main.js Runtime: component loading, nav, animations
styles/main.css Global stylesheet
includes/ Generated EN nav/footer (do not edit directly)
de/ Generated DE output (do not edit directly)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages