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.
| Source | Front matter | URL | Written to |
|---|---|---|---|
about.md | /about/ | about/index.html | |
index.bxm | / | index.html | |
docs/index.md | /docs/ | docs/index.html | |
posts/my-file.md | type: post | /posts/my-file/ | posts/my-file/index.html |
posts/my-file.md | type: post, slug: nice | /posts/nice/ | posts/nice/index.html |
404.md | /404.html | 404.html | |
feed.bxm | fileExt: xml | /feed.xml | feed.xml |
x.md | permalink: /a/b/ | /a/b/ | a/b/index.html |
x.md | permalink: a/b/ | /a/b/ | a/b/index.html |
x.md | permalink: /a/b.html | /a/b.html | a/b.html |
x.md | permalink: /sitemap.xml | /sitemap.xml | sitemap.xml (fileExt becomes xml) |
posts/p.md | type: post, permalink: /p/ | /p/ | p/index.html |
x.md | permalink: /a.xml, fileExt: rss | /a.xml | a.xml (fileExt stays rss) |
The rules:
- An explicit
permalinkalways wins, for every type. Ending in/, it writesindex.htmlunder 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
indexdocuments and the root404document, which keep the URLs below. - Otherwise, a document is written to
<dir>/<name>/index.htmlwith the URL/<dir>/<name>/.<name>isslugwhen set, otherwise the file name. index.mdorindex.bxmin a folder is written to<dir>/index.htmlwith the URL/<dir>/.404.mdat the site root is written to/404.html, where static hosts look for it.- A non-HTML
fileExtkeeps the flat form<dir>/<name>.<ext>.
Two documents that resolve to the same output file fail the build.
Permalink patterns
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/.
| Token | Value |
|---|---|
:year | Year of the document's resolved date, 4 digits |
:month, :day | Month and day of the resolved date, 2 digits |
:slug | Front matter slug if set, else the file name without extension and without a YYYY-MM-DD- prefix |
:name | File name without extension, unchanged |
:title | Slugified title, or :slug when the title is empty |
:dir | Folder 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:
baseUrl | pathPrefix | siteUrl |
|---|---|---|
"" (default) | "" | "" |
"/repo" or "/repo/" | /repo | "" |
"https://example.com" | "" | https://example.com |
"https://user.github.io/repo/" | /repo | https://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:
| Helper | With 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).