Permalink Templates

Permalinks refer to the relative URL for your pages. Cobalt supports a flexible way to build permalinks, allowing you to leverage various Liquid template variables.

Permalinks are configured in the frontmatter. When configuring a permalink, you're most likely to want to set it as a default

Example:

title: My first Blogpost
layout: posts.liquid
permalink: /some/other/file.html

Results in

Note: Permalinks templates must start with a /.

Pretty URLs

When you omit the file extension (e.g. .html) in your permalink, Cobalt will treat the permalink as a folder and create the file with the name index.html.

Example:

title:   My first Blogpost
layout: posts.liquid
permalink: /some/other/file

Results in

Template Variables

VariableDescription
parentThe directory path to the file. e.g. If the file is posts/some/file.md, then parent will be posts/some.
nameThe file name without the extension. e.g. If the file is posts/some/file.md, then name will be file.
extThe output file extension.
slugThe page's slug.
categoriesThe categories for the page, separated by /. e.g. If the frontmatter's categories are "Animals", "Dogs", then the permalink's categories is animals/dogs.
yearThe published_date's year.
i_monthThe published_date's month.
monthThe published_date's month, with a leading 0.
i_dayThe published_date's day.
dayThe published_date's day, with a leading 0.
hourThe published_date's hour, 24-hour clock, with a leading 0.
minuteThe published_date's minute, with a leading 0.
secondThe published_date's second, with a leading 0.
dataThe frontmatter data.

Example:

title: Corgi
layout: posts.liquid
categories:
  - Animals
  - Dogs
permalink: /{{categories}}/{{slug}}

Results in

Built-in Permalink Styles

Cobalt also provides some built-in permalink templates.

Permalink StyleURL Template
path/{{parent}}/{{name}}{{ext}}

Example file some/other/file.md:

title:   My first Blogpost
layout: posts.liquid
permalink: path

Results in