Skip to main content

An MkDocs plugin allowing links to your pages using a custom alias

Project description

mkdocs-alias-plugin

PyPI version License: MIT example workflow

An MkDocs plugin allowing links to your pages using a custom alias.

The use syntax of the alias is reminiscent of MediaWiki links.

Rationale

I maintain a fairly large wiki and occasionally will restructure parts of it, resulting in many broken links. This plugin allows me to separate the wiki contents from the file system structure and resolves the paths during build time. Maybe this plugin will help you out as well.

Usage

In the meta section atop your page add an alias section:

---
alias:
    name: wuthering-heights
    text: Wuthering Heights, a novel by Emily Brontë
---

Then, using the alias in the markdown content of your pages:

The song references [[wuthering-heights]].

If you'd like to supply your own link text instead, you can do so using a pipe to separate it from the alias:

The song references [[wuthering-heights|Wuthering Heights]].

Installation

Install the package with pip:

pip install mkdocs-alias-plugin

Then in your mkdocs.yml file add the following entry to the plugins section:

plugins:
  - alias

Options

You may customize the plugin by passing options in mkdocs.yml:

plugins:
    - alias:
        verbose: true

verbose

You may use the optional verbose option to print more information about which aliases were used and defined during build. The default value is false.

Troubleshooting

My alias not being replaced

Or: WARNING - Alias 'my-alias' not found

The alias could not be found in the defined aliases, usually due to a typo. Enable verbose output in the plugin's configuration to display all of the found aliases.

"Alias already defined"

You're getting a message resembling this in your output:

WARNING - page-url: alias alias-name already defined in other-url, skipping.

Aliases must be unique. Ensure that you're not redefining the same alias for a different page. Rename one of them and the warning should go away.

Local Development

pip install -e /path/to/mkdocs-alias-plugin/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs-alias-plugin-0.1.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

mkdocs_alias_plugin-0.1.1-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page