URLs & Permalinks

Where each document is written, permalink patterns per type, and serving a site from a sub-path.

URL scheme

URLs are folder-style, so a built site works on any static host without a router or rewrite rules.

SourceFront matterURLWritten to
about.md /about/about/index.html
index.bxm /index.html
docs/index.md /docs/docs/index.html
posts/my-file.mdtype: post/posts/my-file/posts/my-file/index.html
posts/my-file.mdtype: post, slug: nice/posts/nice/posts/nice/index.html
404.md /404.html404.html
feed.bxmfileExt: xml/feed.xmlfeed.xml
x.mdpermalink: /a/b//a/b/a/b/index.html
x.mdpermalink: a/b//a/b/a/b/index.html
x.mdpermalink: /a/b.html/a/b.htmla/b.html
x.mdpermalink: /sitemap.xml/sitemap.xmlsitemap.xml (fileExt becomes xml)
posts/p.mdtype: post, permalink: /p//p/p/index.html
x.mdpermalink: /a.xml, fileExt: rss/a.xmla.xml (fileExt stays rss)

The rules:

  • An explicit permalink always wins, for every type. Ending in /, it writes index.html under it; otherwise it is the file path as written. A leading / is added if missing.
  • Otherwise a permalink pattern for the document's type, when configured, is used, except for index documents and the root 404 document, which keep the URLs below.
  • Otherwise, a document is written to <dir>/<name>/index.html with the URL /<dir>/<name>/. <name> is slug when set, otherwise the file name.
  • index.md or index.bxm in a folder is written to <dir>/index.html with the URL /<dir>/.
  • 404.md at the site root is written to /404.html, where static hosts look for it.
  • A non-HTML fileExt keeps the flat form <dir>/<name>.<ext>.

Two documents that resolve to the same output file fail the build.

The permalinks config key maps a document type to a URL pattern:

json{
	"permalinks": {
		"post": "/:year/:month/:slug/"
	}
}

With this, posts/2026-03-01-launch.md (type post) is written to 2026/03/launch/index.html with the URL /2026/03/launch/.

TokenValue
:yearYear of the document's resolved date, 4 digits
:month, :dayMonth and day of the resolved date, 2 digits
:slugFront matter slug if set, else the file name without extension and without a YYYY-MM-DD- prefix
:nameFile name without extension, unchanged
:titleSlugified title, or :slug when the title is empty
:dirFolder of the source file relative to the site root, without leading or trailing /; empty at the root (a resulting // becomes /)

The result follows the same rules as an explicit permalink (ending in / writes index.html). An explicit permalink in the front matter, or from folder defaults, still wins. An unknown token fails the build naming the document. A pattern applies to every document of its type except index.md/index.bxm in any folder and 404.md/404.bxm at the site root: with a pattern for page, index.bxm stays at /, docs/index.md at /docs/ and 404.md at /404.html. Give such a document an explicit permalink to move it.

Base URL

Set baseUrl when the site is not served from the root of its host, or to get absolute URLs for feeds and sitemaps:

baseUrlpathPrefixsiteUrl
"" (default)""""
"/repo" or "/repo/"/repo""
"https://example.com"""https://example.com
"https://user.github.io/repo/"/repohttps://user.github.io/repo

pathPrefix and siteUrl are also readable as config.pathPrefix and config.siteUrl, unless ssg-config.json defines keys with those names (see Configuration). pathPrefix is put in front of every prc.permalink, every pagination href, and the permalink of every document in collections; prc.outFile is not changed, so the files are written to the same place. prc.absoluteUrl is siteUrl plus the page's path when siteUrl is set.

URLs you write by hand in templates need the prefix too. Use the helpers, callable from any template, view, layout or applicationHelper.bxm function:

HelperWith baseUrl https://user.github.io/repo/With baseUrl ""
relUrl( "/assets/site.css" )/repo/assets/site.css/assets/site.css
absUrl( "/feed.xml" )https://user.github.io/repo/feed.xml/feed.xml

A path without a leading / gets one. An argument that already has a scheme (https:, mailto: and so on) or starts with // or # is returned unchanged by both. absUrl returns the same as relUrl when baseUrl has no scheme and host. A function named relUrl or absUrl in your applicationHelper.bxm replaces the built-in one.

prc.permalink, pagination hrefs and the permalinks in collections already include the prefix, so use them as they are: relUrl( prc.permalink ) adds the prefix a second time (/repo/repo/about/).

serve ignores baseUrl (see the notes under Commands and flags).