If you like my work, please consider supporting its development.

The link shortcode provides a single way to create links to other content pages, to page resources, site assets, and static files. The generated links respect the selected reference type, if one is configured.

link can be called with either one unnamed parameter corresponding to the path to a content file to link to (following the rules of ref and relref) or two parameters named path and type indicating the path to the resource and what kind of resource it is.

This limitation is due to Midnight not knowing where a site’s static content and assets folders are. It could guess using the defaults, but if a site doesn’t use the default locations, the shortcode would be broken. That’s not acceptable, so named parameters it is.

Valid resource types are:

  • "content": any content page, including list pages using _index.md
  • "resource": a page resource. path should be relative to the current page
  • "asset": a site asset. path should be relative to the assets folder
  • "static": a file in the static folder. path should be relative to the static folder.

Due to the limitations mentioned above, Midnight cannot determine the existence of files in the static directory. If you create a static link, be sure to check that you can access the file correctly.

Examples