From cfaab13e453f5cde25804823cde86d3e9d293b4a Mon Sep 17 00:00:00 2001 From: noether Date: Sun, 11 Oct 2026 09:00:07 -0600 Subject: [PATCH] docs: rewrite README with architecture section + full make reference The README now documents: - Architecture: the static build/serving model, the content -> public/ -> pagefind/ data flow, the SCSS compile pipeline (why the Hugo extended build is required, SRI fingerprinting), where customizations live (_variables.scss table, search.html), the data-pagefind-body index-scoping mechanism, the #search CSS cascade trick, and the four Pagefind 1.5.2 quirks the UI works around (stretched form, no-op Enter, empty thumbnail, UA-yellow marks) - Every Makefile target with what it does and the gotchas (serve does not rebuild; serve-lan is plain static; build runs --gc) - Search usage incl. the new keyboard navigation, and a table of the current #search customization values - Dead-link automation (internal/external split, idempotent comment-out, daily cron job) - Troubleshooting for the new failure modes and a do-not-commit list --- README.md | 509 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 425 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index f7c358a..9024060 100644 --- a/README.md +++ b/README.md @@ -1,90 +1,431 @@ -# Building The Website -## Clone Repository -`git clone https://dev.libertytools.io/adminuser/libertytoolsio.git` +# Liberty Tools (libertytools.io) — Hugo static site + +A Hugo site built on the [hugo-book](https://github.com/alex-shpak/hugo-book) theme, +with **Pagefind** client-side search and **lychee**-based dead-link checking. This +document is the single reference for understanding the architecture, building, +previewing, searching, and maintaining the site. + +> If you only need to build and preview, jump to +> [Build & preview (§4)](#4-build--preview-make-commands). Everything you normally +> type is a `make` target. + +--- + +## Table of contents + +- [Architecture](#architecture) +- [1. Clone](#1-clone) +- [2. Prerequisites (install once)](#2-prerequisites-install-once) +- [3. Configuration](#3-configuration) +- [4. Build & preview (make commands)](#4-build--preview-make-commands) +- [5. Search (Pagefind)](#5-search-pagefind) +- [6. Dead links](#6-dead-links) +- [7. Troubleshooting](#7-troubleshooting) +- [8. Do not commit](#8-do-not-commit) +- [Repository layout](#repository-layout) + +--- + +## Architecture + +The site is a **fully static** output: no server-side rendering at request time, no +database, no runtime. Hugo renders the markdown to plain HTML files *at build time*; +a search index is generated from those files; and a trivial static file server +(delivering the built directory) is all that runs in front of a browser. + +### The three moving parts + +| Component | Role | +|--------------|---------------------------------------------------------------------------------------| +| **Hugo** | The static site generator. Reads `content/*.md` + the theme, emits `public/`. | +| **hugo-book** | The theme (vendored under `themes/hugo-book/`). Layouts, SCSS styling, menu/TOC. | +| **Pagefind** | Client-side full-text search. Indexes the built `public/` into `public/pagefind/`. | +| **lychee** | Dead-link checker (used only by the `link-check`/`link-fix`/`external-check` targets).| + +Only Hugo and Node (for Pagefind's `npx` wrapper) are required to build. `lychee` is +needed only if you run the dead-link targets. + +### Content → build → serve, data flow -## Run Makefile -The `Makefile` in the root of the directory will run the following two commands: -``` bash -hugo server & -npx -y pagefind --site public --serve ``` -The first command will run and compile the `hugo` website and any changes made. The second command will build and re-index the search bar index. - -To build the website, simply run -``` bash -make run -``` -in the project root to run those two commands found in the `Makefile`. - - -# Viewing Changes to Website Locally -After running the `Makefile` you should get an output like this" - -``` shell -hugo server & -npx -y pagefind --site public --serve -Watching for changes in /path/to/libertytools_sites/dev_lt/libertytoolsio/{archetypes,content,data,layouts,static,themes} -Watching for config changes in /path/to/libertytools_sites/dev_lt/libertytoolsio/config.toml, /path/to/libertytools_sites/dev_lt/libertytoolsio/themes/hugo-book/hugo.toml -Start building sites … -hugo v0.151.0-c70ab27ceb841fc9404eab5d2c985ff7595034b7+extended linux/amd64 BuildDate=2025-10-02T13:30:36Z VendorInfo=gohugoio - - - │ EN -──────────────────┼───── - Pages │ 27 - Paginator pages │ 0 - Non-page files │ 65 - Static files │ 106 - Processed images │ 0 - Aliases │ 0 - Cleaned │ 0 - -Built in 100 ms -Environment: "development" -Serving pages from disk -Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender -Web Server is available at http://localhost:1313/ (bind address 127.0.0.1) -Press Ctrl+C to stop - -Running Pagefind v1.5.2 (Extended) -Running from: "/path/to/libertytools_sites/dev_lt/libertytoolsio" -Source: "public" -Output: "public/pagefind" - -[Walking source directory] -Found 50 files matching **/*.{html} - -[Parsing files] -Did not find a data-pagefind-body element on the site. -↳ Indexing all elements on the site. - -[Reading languages] -Discovered 2 languages: en-us, en - -[Building search indexes] -Total: - Indexed 2 languages - Indexed 48 pages - Indexed 6934 words - Indexed 0 filters - Indexed 0 sorts - -┌─────────────────────────────────────────────────────────────────────────┐ -│ Pagefind found references to the Default UI (pagefind-ui.js) │ -│ on your site. The Default UI is supported and will continue │ -│ to work. │ -│ │ -│ As of 1.5.0, if you are setting up a new integration, use the │ -│ Component UI instead. It includes a search modal, better │ -│ accessibility and customization: https://pagefind.app/docs/search-ui/ │ -└─────────────────────────────────────────────────────────────────────────┘ - -Finished in 0.067 seconds - -Serving the Pagefind Playground at http://localhost:1414/pagefind/playground/ -Serving "public" at http://localhost:1414 + ┌──────────────────────────────────────────────┐ + │ content/ │ + │ *.md pages + images (the source) │ + └──────────────────────┬───────────────────────┘ + │ make build (hugo --gc) + ▼ + ┌──────────────────────────────────────────────┐ + │ public/ │ + │ rendered static HTML + fingerprinted CSS/JS │ + │ (hugo-book SCSS compiled by the extended │ + │ build; each asset hash-named + SRI-checked)│ + └──────────────────────┬───────────────────────┘ + │ make index (pagefind --site public) + ▼ + ┌──────────────────────────────────────────────┐ + │ public/pagefind/ │ + │ Pagefind search index (WASM + JSON) │ + │ — ships inside public/, so any static │ + │ server can serve a working search │ + └──────────────────────┬───────────────────────┘ + │ make serve / make serve-lan + ▼ + browser (any machine on the network) ``` -Copy `http://localhost:1414` into your web browser and you should then see the website as it is with all the changes made, but only served from your local machine. This version of the site is not public facing. +Two consequences worth internalizing: +1. **`public/` is the single source of truth for what is served.** Both the search + index and every preview server read from it. If the site "isn't showing your + change," the build hasn't run — re-run `make index`. +2. **The Pagefind bundle lives inside `public/`.** That's why `make serve-lan` (a plain + Python static server) serves working search with zero extra setup — there is no + special search server required. +### The theme SCSS pipeline + +`html-head.html` compiles the theme's stylesheet on every build: + +``` +book.scss → resources.ExecuteAsTemplate → css.Sass → resources.Minify → resources.Fingerprint +``` + +`css.Sass` is why the **Hugo *extended*** edition is mandatory (the standard build has +no SCSS compiler). `resources.Fingerprint` hashes the output into the filename +(`book.min..css`) and embeds an SRI `integrity` attribute on the ``; a +single byte change in the CSS produces a new filename, which is why old cached +stylesheets never collide with new ones. + +### Where your customizations live + +Two files hold all site-level customization — you rarely need to touch anything else: + +- **`themes/hugo-book/layouts/_partials/docs/search.html`** — the entire search UI: + the Pagefind `new PagefindUI({...})` config, the `#search`-scoped `