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}"
        }
      }
    ]
  }
}

Each post type can take the following values:

PropertyTypeDescription
typestringThe IndieWeb post type. Required.
namestringThe name you use for this post type on your own site. You needn’t specify this value, but some Micropub clients use this value in their publishing interfaces.
hstringMicroformat vocabulary to use. Optional, defaults to "entry".
discoverystringProperty to use for post type discovery. Optional.
fieldsArray[object]Which input fields to display in Indiekit’s publishing interface. Micropub clients may use these values in their publishing interfaces.
fields[].requiredbooleanInput field is required. Micropub clients may use this value in their publishing interfaces.
post.pathstringWhere posts should be saved in your content store. Required.
post.urlstringPermalink (the URL path) for posts on your website. Required.
media.pathstringWhere media files should be saved in your content store. Required
media.urlstringPublic 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. ↩︎