Foundry is a Markdown-first CMS written in Go. It keeps content in files, renders through themes, extends through plugins, and supports both static output and local preview serving.
The project is aimed at teams that want a file-based workflow without giving up CMS-style features such as taxonomies, fields, feeds, plugin hooks, and an admin surface.
- Stores pages and posts as Markdown with frontmatter
- Supports language-aware routing and content grouping
- Builds a normalized site graph in memory
- Uses themes for layouts, partials, and theme assets
- Uses plugins for hooks, asset injection, and runtime extensions
- Generates RSS and sitemap output
- Publishes static output to
public/ - Serves the site locally with live reload during development
- Tracks document, template, data, and taxonomy dependencies for incremental rebuilds
cmd/
foundry/ main CLI entrypoint
plugin-sync/ generated plugin import synchronizer
internal/
admin/ admin auth, HTTP handlers, service layer, UI templates
assets/ asset sync and CSS bundling
commands/ CLI command implementations
config/ config loading, editing, validation
content/ document parsing, loading, site graph assembly
data/ data file loading
deps/ dependency graph and incremental rebuild planning
feed/ RSS and sitemap generation
markup/ Markdown rendering
plugins/ plugin metadata, loading, lifecycle, sync
renderer/ template rendering and output writing
router/ URL assignment
server/ preview server, watcher, incremental rebuild orchestration
site/ higher-level graph loading helpers
taxonomy/ taxonomy indexing and archive helpers
theme/ theme management and validation
plugins/ built-in plugins
themes/ installed themes
content/ project content
data/ project data files
docs/ GitHub Pages site and published coverage
scripts/ release and maintenance utilities
Foundry keeps a clean separation between content loading, route assignment, rendering, and runtime orchestration.
The main pipeline is:
config -> content/data load -> site graph -> route assignment
-> dependency graph -> renderer -> build output or preview server
Two graph types matter:
SiteGraph: the in-memory representation of documents, routes, taxonomies, config, and loaded dataDependencyGraph: the rebuild graph used to decide which outputs must be regenerated after a change
The dependency graph includes taxonomy archive outputs, so incremental rebuilds can target both document pages and taxonomy pages.
Foundry uses:
go fmtfor Go codeprettierfor JS, CSS, HTML, and Markdown assets/docs
Install the formatter tooling once:
npm installThen run:
make fmt
make fmt-web
make fmt-allFoundry now ships two official framework-agnostic JavaScript SDKs under sdk/:
sdk/adminsdk/frontend
They exist to give admin frontends, plugin UIs, and JS-powered themes a supported client contract instead of forcing each consumer to hand-roll fetch logic against unstable internal endpoints.
The Admin SDK targets the authenticated admin API under admin.path + /api.
The Frontend SDK targets the public Foundry platform surface under /__foundry, with a live JSON API in preview/server mode and generated static artifacts under public/__foundry/ for built sites.
The shared SDK core handles:
- request construction
- normalized JSON/error handling
- capability discovery helpers
- common client configuration
The current official browser entrypoints are:
/__foundry/sdk/admin/index.js
/__foundry/sdk/frontend/index.js
Example:
import { createAdminClient } from '/__foundry/sdk/admin/index.js';
import { createFrontendClient } from '/__foundry/sdk/frontend/index.js';
const admin = createAdminClient({ baseURL: '/__admin' });
const frontend = createFrontendClient({ mode: 'auto' });Current capability discovery endpoints:
- admin:
<admin.path>/api/capabilities - frontend:
/__foundry/api/capabilities
Built sites also emit frontend SDK data artifacts under:
public/__foundry/
capabilities.json
site.json
navigation.json
routes.json
collections.json
search.json
preview.json
content/<id>.json
sdk/...
The shipped themes use these SDKs too:
- the default admin theme imports the Admin SDK from
/__foundry/sdk/admin/index.js - the default frontend theme boots a small SDK-based runtime from
/theme/js/foundry-theme.js
Plugin-defned admin pages and widgets can also target a stable shell contract now. A plugin can declare admin page and widget bundles in plugin.yaml, Foundry exposes those bundles under <admin.path>/extensions/<plugin>/..., and the default admin shell will automatically import them when their page or widget slot is active. The shell dispatches foundry:admin-extension-page and foundry:admin-extension-widget and exposes window.FoundryAdmin so plugin code can mount against a supported runtime surface instead of private admin internals.
- Go
1.22or newer - A working
PATHthat includes$(go env GOPATH)/binif you install withgo install
Install the CLI:
go install github.com/sphireinc/foundry/cmd/foundry@latestVerify the install:
foundry versionIf you are working from a local checkout instead of a global install, you can run:
go run ./cmd/foundry versionFoundry expects a file-based project layout. The quickest way to get running is to start with this shape:
content/
config/
site.yaml
pages/
index.md
posts/
images/
uploads/
data/
themes/
plugins/
Minimal content/config/site.yaml (though you can just cope the example.site.yaml):
title: My Site
base_url: http://localhost:8080
theme: default
content_dir: content
public_dir: public
themes_dir: themes
data_dir: data
plugins_dir: plugins
server:
addr: :8080
live_reload: true
live_reload_mode: streamMinimal content/pages/index.md:
---
title: Home
---
# Hello from FoundryStart the local preview server from the project root:
foundry serveThen open http://localhost:8080/.
To produce static output:
foundry buildGenerated files will be written to public/.
For preview-oriented output that includes non-published workflow states:
foundry build --previewThat also writes a preview manifest at public/preview-links.json.
foundry version
foundry build
foundry build --preview
foundry build --env preview --target production
foundry serve
foundry serve --debug
foundry serve-preview
foundry plugin list --enabled
foundry theme list
foundry routes check
foundry admin hash-password your-password- Update
content/config/site.yaml. - Add pages and posts under
content/pagesandcontent/posts. - Put media under the dedicated collection roots:
content/images,content/videos,content/audio, andcontent/documents. - Reference media from Markdown with the
media:scheme. - Run
foundry serveduring development. - Run
foundry buildbefore publishing or checking generated output.
Embedded media uses normal Markdown image syntax:

File links use normal Markdown link syntax:
[Download the spec](media:documents/spec-sheet.pdf)Admin uploads return stable references in the same format, for example:
media:images/posts/launch/diagram.png
media:videos/posts/launch/demo.mp4
media:documents/posts/launch/spec-sheet.pdf
If a page appears to hang during local preview, run foundry serve --debug to emit per-request timing plus runtime snapshots, including:
- heap allocation and in-use heap
- stack and total runtime memory
- goroutine count
- active request count
- GC count
- process user/system CPU time and request CPU percentage estimates
If live reload causes browser connection stalls in development, switch server.live_reload_mode from stream to poll. stream uses Server-Sent Events and refreshes immediately. poll trades a small delay for simpler connection behavior.
Foundry supports environment-specific config overlays and named deploy targets.
If content/config/site.preview.yaml exists, it can be layered on top of the base config with:
foundry build --env previewNamed targets are configured under deploy.targets and applied with:
foundry build --target production
foundry build --env staging --target edgeIf deploy.default_target is set, Foundry applies that target automatically when no explicit --target flag is provided.
foundry doctor now reports timing breakdowns for:
- plugin config hooks
- content/data loading
- route assignment
- route hooks
- asset sync
- renderer
- feed generation
foundry validate now checks:
- broken internal links
- broken
media:references - missing layout templates
- orphaned media
- duplicate URLs
- duplicate type/lang slug combinations
- taxonomy inconsistencies
The content command set also includes portability and migration helpers:
foundry content export bundle.zip
foundry content import markdown ./legacy-markdown
foundry content import wordpress ./wordpress.xml
foundry content migrate layout page landing --dry-run
foundry content migrate field-rename marketing old_field new_field --dry-runFoundry currently supports two primary document types:
pagepost
Content is loaded from:
content/pagescontent/postscontent/imagescontent/videoscontent/audiocontent/documents
Language variants are represented by a leading language directory. For example:
content/pages/about.md
content/pages/fr/about.md
content/posts/launch.md
content/posts/fr/launch.md
Markdown files use frontmatter for metadata such as:
titlesluglayoutdraftsummarydateupdated_attagscategories- custom
taxonomies fields- arbitrary
params
Foundry supports images, video, audo, and downloadable files through the media: reference scheme.
media:images/...resolves to/images/...media:uploads/...resolves to/uploads/...media:assets/...resolves to/assets/...
The renderer infers the output element from the target file extension:
- image files render as
<img> - video files render as
<video controls> - audio files render as
<audio controls> - other files remain standard links
The main config file is typically:
content/config/site.yaml
Important config groups:
admin: admin service settingsserver: preview server settingscontent: content directory conventions and default layoutstaxonomies: taxonomy definitions and archive layoutsplugins: enabled pluginssecurity: security-sensitive rendering settingsfeed: RSS and sitemap output paths
admin.path controls where the themeable admin shell is mounted. By default it is /__admin. The shell itself is public so the browser can load HTML, CSS, and JavaScript. Authenticated API access is session-based by default.
Admin users live in a filesystem-backed YAM file, which defaults to:
content/config/admin-users.yaml
Example:
users:
- username: admin
name: Admin User
email: admin@example.com
role: admin
password_hash: pbkdf2-sha256$...Generate a password hash with:
foundry admin hash-password "your-password"Or generate a starter YAML snippet with:
foundry admin sample-user admin "Admin User" admin@example.com "your-password"Browser sessions are stored in a secure cookie scoped to admin.path, expire after 30 minutes of inactivity by default, and are renewed while the user remains active.
admin.access_token is now optional. If set, it still works for API automation with:
Authorization: Bearer <token>X-Foundry-Admin-Token: <token>
Admin themes live under:
themes/admin-themes/<name>/
admin-theme.yaml
index.html
assets/
admin.css
admin.js
admin-theme.yaml is the admin-theme manifest. It now supports:
admin_apisdk_versioncompatibility_versioncomponentswidget_slotsscreenshots
Both shipped themes now declare and validate against the current SDK contract:
- frontend theme
sdk_version: v1 - admin theme
sdk_version: v1
The current stable admin-theme component contract is:
shellloginnavigationdocumentsmediausersconfigpluginsthemesaudit
The current stable admin-theme widget-slot contract is:
overview.afterdocuments.sidebarmedia.sidebarplugins.sidebar
Set the active admin theme with:
admin:
enabled: true
path: /__admin
theme: default
users_file: content/config/admin-users.yaml
session_ttl_minutes: 30admin.local_only is a convenience restriction for local development. It should not be treated as the only security boundary in front of a reverse proxy.
The dfault admin theme now includes:
- a structured frontmatter editor that stays in sync with raw Markdown
- media-picker insertion for stable
media:references - document and media history/trash views with restore and purge actions
- restore-preview flows that load a diff before a document restore is committed
- media replacement while preserving the canonical reference path
- an audit log view
- dedicated user-security flows for password reset tokens, TOTP setup/disable, and session revocation
- a Debug page with runtime, content, storage, integrity, activity, and persisted build-report visibility when
admin.debug.pprofis enabled - keyboard shortcuts:
Cmd/Ctrl+Ssave the current formCmd/Ctrl+Enterpreview the current documentCmd/Ctrl+Kopen the command paletteShift+/toggle shortcut helpg d,g m,g u,g ajump to Documents, Media, Users, and Audit
The admin UI also includes breadcrumbs, toast notifications, unsaved-change warnings, clearer error panels, a command palette for fast navigation and creation shortcuts, review/scheduled overview queues, and client-side pagination/sorting for the major management tables.
security.allow_unsafe_html controls whether raw HTML in Markdown is preserved in rendered output.
server.live_reload turns live reload on during local preview.
server.live_reload_mode controls the transport:
stream: uses a long-lived SSE connection to/__reloadpoll: polls/__reload/pollevery 1.5 seconds and reloads when the rebuild version changes
Use poll if your browser or proxy environment is sensitive to long-lived local connections.
The preview/admin server uses explicit read, write, and idle timeouts by default.
Static builds now also emit a frontend search index at:
public/search.json
The generated and live search surfaces now include snippets, and the search APIs apply simple weighted ranking so title and summary matches are promoted ahead of body-only matches.
foundry validate now checks for:
- broken
media:references - broken internal links to routes and static files
Themes live under themes/<name>/.
A theme typically contains:
themes/default/
assets/
css/
layouts/
base.html
index.html
page.html
post.html
list.html
partials/
head.html
header.html
footer.html
theme.yaml
Themes are responsible for:
- page and post presentation
- shared base layout
- taxonomy archive templates
- theme-specific assets
Theme manifests now support richer metadata:
supported_layoutsconfig_schemascreenshotscompatibility_version
Launch themes are also expected to support the current minimum slot contract:
head.endbody.startbody.endpage.before_mainpage.after_mainpage.before_contentpage.after_contentpost.before_headerpost.after_headerpost.before_contentpost.after_contentpost.sidebar.toppost.sidebar.overviewpost.sidebar.bottom
Theme validation now checks both of these conditions:
- the theme manifest declares the required slots
- the corresponding layouts actually render those slots
It also checks:
- required layouts and partials
- template references to missing partials/layouts
- template parse failures with diagnostics suitable for admin reporting
Plugins live under plugins/<name>/ and are registered through generated imports.
Current plugin capabilities include:
- lifecycle hooks during load/build/serve
- route and rendering hooks
- HTML slot injection
- asset injection
- plugin validation and dependency checks
Plugin manifests now also support:
dependenciescompatibility_versionconfig_schemascreenshots
Plugin installation is intentionally conservative now: install sources are restricted to GitHub over https or git@github.com. Installing a plugin still means trusting third-party code, so treat it as a supply-chain boundary.
Plugin management is safer now:
- updates keep rollback snapshots under
plugins/.rollback/<name>/... - plugins can be rolled back to the latest preserved snapshot
- admin plugin records now include health/diagnostic reporting, dependency/config metadata, and rollback availability
Foundry maintains a dependency graph that relates:
- source files to documents
- templates to outputs
- data keys to outputs
- documents to taxonomy archives
- taxonomy archives to rendered URLs
When possible, the preview server rebuilds only the affected outputs instead of running a full site rebuild.
The asset pipeline can:
- copy content assets
- copy images
- copy uploads
- copy theme assets
- copy enabled plugin assets
- build a bundled CSS file in
public/assets/css/foundry.bundle.css
Asset roots and plugin/theme names are validated as safe paths, and symlinked asset files are rejected.
The repository publishes a small docs site from docs/ that includes:
- a project overview
- the CLI contract
- the latest HTML coverage report generated in CI
Useful commands while working on the repo:
go test ./...
go vet ./...
go run ./cmd/plugin-syncThe main CI workflow also verifies formatting, syncs generated plugin imports, builds the project, runs tests, and publishes the coverage report to GitHub Pages on main.
