Skip to content

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:

  1. Content Walk: The content/ directory is recursively scanned for all .md files.
  2. Frontmatter Parse: The frontmatter of each file is parsed to extract metadata such as title, layout, render flag, and description.
  3. AST Transform: The Markdown content is parsed into an Abstract Syntax Tree (AST). A custom transformer walks the AST, converting relative .md and [[wiki]] links into their output URLs, and tracking internal links to build the site’s graph.
  4. HTML Render: The processed Markdown is converted to safe, sanitized HTML and injected into the appropriate layout templates.
  5. 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.
  6. 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.
  7. Asset Copy: Static assets like images and CSS are copied verbatim into the output directory, respecting any ignore patterns.
  8. JSON Output: Finally, site metadata and graph structures are exported as JSON for advanced client-side functionality.
  9. Discovery Feeds: If any rendered page has a valid date in its frontmatter, the build emits a deterministic feed.xml RSS 2.0 feed. Pages marked render: false are excluded. Feed links use siteurl when 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:

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:

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.