La Famille / Field notes
How the Generator Works
La Famille is a static site generator written in Go that transforms Markdown content into fully-fledged HTML pages with associated metadata. Below is an overview of the internal pipeline and the packages that drive it.
The Multi-Pass Pipeline
The build process is executed in several distinct passes to ensure accurate linking, rendering, and output generation:
- Content Walk: The
content/directory is recursively scanned for all.mdfiles. - Frontmatter Parse: The frontmatter of each file is parsed to extract metadata such as title, layout, render flag, and description.
- AST Transform: The Markdown content is parsed into an Abstract Syntax Tree (AST). A custom transformer walks the AST, converting relative
.mdand[[wiki]]links into their output URLs, and tracking internal links to build the site’s graph. - HTML Render: The processed Markdown is converted to safe, sanitized HTML and injected into the appropriate layout templates.
- Stub Generation: For any internal links pointing to non-existent pages, HTML stubs are automatically generated. Wiki-link stubs are titled
Unresolved Note: <target>and appear as stub nodes in the graph with their inbound links. - Vault Navigation: Every build emits
unresolved-notes/index.html, listing generated stubs. Rendered content pages include a “Linked from” panel populated from the backlinks already collected by the build. - Asset Copy: Static assets like images and CSS are copied verbatim into the output directory, respecting any ignore patterns.
- JSON Output: Finally, site metadata and graph structures are exported as JSON for advanced client-side functionality.
- Discovery Feeds: If any rendered page has a valid
datein its frontmatter, the build emits a deterministicfeed.xmlRSS 2.0 feed. Pages markedrender: falseare excluded. Feed links usesiteurlwhen configured and root-relative URLs for local builds; no feed is retained when there are no dated rendered pages.
Wiki Links
Use [[Page Name]] to link to a page by source filename or frontmatter title.
Use [[target|alias]] to choose the displayed link text, or
[[target#Heading Name]] to link to an automatically generated heading ID.
Targets resolve relative to the current page first, then the content root.
Unknown targets generate a stub titled Unresolved Note: <target>; its graph
node records the referring pages and its title is included in meta.json.
Key Internal Packages
The generator’s functionality is cleanly separated into several internal packages:
internal/content: Responsible for walking the file system and parsing the YAML frontmatter from Markdown files into structuredFileMetaobjects. It also handles basic validation (e.g., date formats, tag normalization).internal/transform: Houses theLinkTransformer, which visits AST nodes during Markdown parsing to rewrite links, enforce clean URLs (using theurl.goutilities), and record missing files for stub generation. It also implements custom inline Goldmark parser structures, specifically theEmojiKitchenParserfor mutating inline CDN emoji stickers.internal/render: Manages the loading, parsing, and execution of HTML templates and partials. It caches templates for performance and injects the live-reload script when running in watch mode.internal/stub: Handles the creation of stub pages for missing files detected during the transform phase. It lists the parent pages that linked to the missing content.internal/generator: Reuses collected backlinks to render “Linked from” panels and the unresolved-notes index.internal/asset: Safely copies static files from the asset directory to the output folder while skipping Go files,testdata, and paths matched by.gitignore.internal/jsonutil: A simple utility package providingWriteJSONto easily write Go structures out as nicely indented JSON files.
Metadata and Graphs
As part of the JSON Output step, the generator produces a few specialized files that provide deep insights into the structure of your site:
graph.json: Describes the entire site structure as a directed graph. It lists every page (node) and the links between them (edges), which is very useful for visualizing the structure or feeding into a knowledge graph system.backlinks.json: A mapping of pages to the list of pages that link to them. This makes it easy to build “Mentioned In” features at the bottom of articles.unresolved-notes/index.html: A generated to-write list linking to every missing-note stub. Rebuilding after a real note is added removes it from this index.meta.json: Provides global site metadata mapped to page IDs, such as page titles, word counts, and tags.search.json: Contains a minified array ofSearchItemstructs, providing a compressed plaintext snippet of each page’s content for client-side search discovery.feed.xml: An RSS 2.0 feed of dated rendered pages, ordered newest first and then by URL. It is omitted when no rendered page has a date.
Explorer Consumption Contract
The Knowledge Graph Explorer renders a payload the generator assembles. After Build() writes graph.json, meta.json, and backlinks.json, the generator invokes internal/graphexplorer.Write(), which renders <output>/graph/index.html from an embedded HTML template (internal/graphexplorer/assets/template.html) and writes <output>/graph/data.json beside it. The template references the companion client bundle (<output>/assets/graph/explorer.{js,css}); the asset pipeline prefers files from the selected project and fills missing runtime files from the release-owned embedded bundle.
data.json is built by graphexplorer.BuildData, which resolves link direction via graph.Adjacency, classifies each node (rendered / raw / stub / orphan), and computes each page’s public URL from the output path it was written to. Doing this once in Go keeps the rules covered by tests and stops the browser and the generator from disagreeing about the same graph.
The explorer’s client runtime never queries the build-time cfg.GraphExplorer flag — it reads only its payload. That decoupling means you can restyle or re-script the page by editing the selected project’s assets/graph/explorer.js (or explorer.css) and re-running la-famille build; the page picks up the override without any Go change. Changing what the graph means, however, belongs in internal/graphexplorer. Setting graph_explorer: false skips both the <output>/graph/ directory and the assets/graph/ bundle, so a disabled explorer ships nothing.
Manual Navigation Snippet
Adding a global nav link to every bundled template would break custom-template compatibility, so the explorer does not auto-inject one. Drop this anywhere inside a layout you control:
<a href="/graph/" rel="nofollow">Knowledge Graph</a>
Root-relative, so it works with or without siteurl.