This plugin gives notes a short address like /s/k3x9a2bq that redirects to them. That helps where a page’s own address is long, such as notes with non-Latin names (/日本語/電卓 becomes /%E6%97%A5%E6%9C%AC%E8%AA%9E/%E9%9B%BB%E5%8D%93 when shared), and for QR codes, slides, posts with character limits or reading a link aloud. This page has one: see the “Copy short link” button below its title.
For information on how to add, remove or configure plugins, see the Configuration page.
The redirects are static HTML pages written by AliasRedirects, which must be enabled (it is by default): the plugin adds each note’s short link to its aliases. Each page with a short link also gets a “Copy short link” button, a <link rel="shortlink"> in its <head> and a shortPermalink field in its content index entry.
Choosing which notes get one
In the default configuration, the plugin is enabled in opt-in mode (optIn: true): only notes that ask for a short link get one. Add this to a note’s frontmatter (in Obsidian, a checkbox property):
---
shortlink: true
---With optIn: false, every note gets a short link, and shortlink: false leaves one out. The blog template (see `quartz create`) uses this. To turn short links off completely, disable the plugin.
How IDs work
A note’s ID is a hash of its path inside the content folder (e.g. notes/My Note.md), in lowercase letters and digits. It stays the same across builds and edits, and is the same on every operating system. Moving or renaming the note changes it, so to keep a short link working after a move, copy its ID into the note’s frontmatter first:
---
shortlink: k3x9a2bq
---You can also choose an ID this way (shortlink: my-talk gives /s/my-talk): letters, digits, - and _. An ID also counts as opting in. With optIn, any other value gives a warning and no short link.
Only notes get short links: not folder or tag pages, pages generated from .canvas or .base files, or drafts. The build warns when two notes have the same ID, which is unlikely (about 1 in 50,000 for a site of 10,000 notes with the default length); give one of them an ID of its own or raise hashLength.
Configuration
This plugin accepts the following configuration options:
optIn: Only notes withshortlink: true(or an ID) in their frontmatter get a short link. Defaults tofalse(every note), and the default configuration sets it totrue.prefix: Folder the short links are in:sgives/s/<id>. Defaults to"s".hashLength: Length of the generated IDs, from4to32. Changing it changes every generated ID. Defaults to8.frontmatterKey: Frontmatter key that turns a note’s short link on or off, or sets its ID.""ignores the frontmatter (not allowed withoptIn). Defaults to"shortlink".showUrl: Show the short link next to the copy button. Defaults tofalse.
Set baseUrl in your configuration so the button copies the full address (https://example.com/s/k3x9a2bq).
Default options
- source: "@quartz-community/short-permalinks"
enabled: true
options:
optIn: true
layout:
position: beforeBody
priority: 25API
- Category: Transformer, Emitter, Component
- Function name:
ExternalPlugin.ShortPermalinks(),ExternalPlugin.ShortPermalinksCheck(),ExternalPlugin.ShortPermalink(). - Source:
quartz-community/short-permalinks - Install:
npx quartz plugin add @quartz-community/short-permalinks(included in the default configuration, in opt-in mode)