Skip to content

Post types

The Micropub API lets you publish a variety of post types, and Indiekit lets you decide how these different types are handled. You can do this by using a publication preset, configuring values manually, or a combination of both.

For example, to use the Jekyll preset but override the note and photo post types, you would add the following to your configuration:

json
{
  "plugins": ["@indiekit/preset-jekyll"],
  "publication": {
    "postTypes": [
      {
        "type": "note",
        "name": "Journal entry",
        "post": {
          "path": "_journal/{yyyy}-{MM}-{dd}-{slug}.md",
          "url": "journal/{yyyy}/{MM}/{slug}"
        }
      },
      {
        "type": "photo",
        "name": "Photograph",
        "post": {
          "path": "_photos/{yyyy}-{MM}-{dd}-{slug}.md",
          "url": "photos/{yyyy}/{MM}/{slug}"
        },
        "media": {
          "path": "media/photos/{yyyy}/{filename}"
        }
      }
    ]
  }
}
{
  "plugins": ["@indiekit/preset-jekyll"],
  "publication": {
    "postTypes": [
      {
        "type": "note",
        "name": "Journal entry",
        "post": {
          "path": "_journal/{yyyy}-{MM}-{dd}-{slug}.md",
          "url": "journal/{yyyy}/{MM}/{slug}"
        }
      },
      {
        "type": "photo",
        "name": "Photograph",
        "post": {
          "path": "_photos/{yyyy}-{MM}-{dd}-{slug}.md",
          "url": "photos/{yyyy}/{MM}/{slug}"
        },
        "media": {
          "path": "media/photos/{yyyy}/{filename}"
        }
      }
    ]
  }
}

Each post type can take the following values:

NameDescription
typeThe IndieWeb post type. Required.
nameThe name you use for this post type on your own site. You needn’t specify this value, but some Micropub clients use it in their publishing interfaces. Required.
post.pathWhere posts should be saved in your content store. Required.
post.urlPermalink (the URL path) for posts on your website. Required.
media.pathWhere media files should be saved in your content store. Required for photo, video and audio post types only.
media.urlPublic accessible URL for media files. This can use the same template variables as media.path. Optional, defaults to media.path.

Path and URL tokens

Values for *.path and *.url can be customised using the following tokens:

TokenPath typeDescription
ypost mediaCalendar year, eg 2020
yyyypost mediaCalendar year (zero-padded), eg 2020
Mpost mediaMonth number, eg 9
MMpost mediaMonth number (zero-padded), eg 09
MMMpost mediaMonth name (abbreviated), eg Sep
MMMMpost mediaMonth name (wide), eg September
wpost mediaWeek number, eg 1
wwpost mediaWeek number (zero-padded), eg 01
Dpost mediaDay of the year, eg 1
DDDpost mediaDay of the year (zero-padded), eg 001
D60post mediaDay of the year (sexageismal), eg 57h
dpost mediaDay of the month, eg 1
ddpost mediaDay of the month (zero-padded), eg 01
hpost mediaHour (12-hour-cycle), eg 1
hhpost mediaHour (12-hour-cycle, zero-padded), eg 01
Hpost mediaHour (24-hour-cycle), eg 1
HHpost mediaHour (24-hour-cycle, zero-padded), eg 01
mpost mediaMinute, eg 1
mmpost mediaMinute (zero-padded), eg 01
spost mediaSecond, eg 1
sspost mediaSecond (zero-padded), eg 01
tpost mediaUNIX epoch seconds, eg 512969520
Tpost mediaUNIX epoch milliseconds, eg 51296952000
uuidpost mediaA random UUID
slugpostProvided slug, slugified name or a 5 character string, eg ycf9o
n[1]post mediaIncremental count of posts (for type) in the same day, eg 1
basenamemedia5 character alpha-numeric string, eg w9gwi
extmediaFile extension of uploaded file, eg jpg
filenamemediabasename plus ext, eg w9gwi.jpg
originalnamemediaOriginal name of uploaded file, eg flower.jpg

  1. Using the n token requires a database to be configured. ↩︎