An MkDocs plugin for linking without specifying the full relative path and other features that ease using the file structure to generate navigation.
Project description
mkdocs-awesome-autolinks
The MkDocs Awesome Autolinks plugin makes it possible to link to pages and images without specifying the full path. For example if there is a page project/general/overview.md this plugin allows you to
link to the page from any other page with just using a part of the path like [overview](overview.md)
or [overview](general/overview.md). This not only works for links to other pages but also to any
other type of file.
In addition to automatically resolving links this plugin complements the
Awesome Nav plugin when using a * glob pattern to automatically include pages in the menu.
Of course the order of menu entries is important, when pages are automatically included the sort
order determines the order in the menu. This can easily be influenced by prefixing a page name or
directory with a number for sorting. Unfortunately this also means that links will more easily break
because of file renaming.
This plugin can automatically remove a prefix from all parts of a link. For example if there is a page 010-project/200-general/999-overview.md this plugin allows you to
link to the page with [overview](overview.md), [overview](general/overview.md) or
[overview](project/general/overview.md). Breaking links because of renaming a file to change the
sort order will no longer be an issue.
The functionality to remove a part of file and directory names can be disabled in mkdocs.yml and
the autolink functionality will continue to work.
Installation
Note: This package requires Python >=3.7 and MkDocs version 1.4 or higher.
Install the package with pip:
pip install mkdocs-awesome-autolinks
Enable the plugin in your mkdocs.yml:
plugins:
- awesome-autolinks
Configuration of the plugin is possible but not necessary if the default behavior suits your need.
Usage
More information will be provided in the future. Here is a short summary of how the automatic linking can be used.
-
The default prefix that is automatically removed from all parts of a link has the following pattern: One or more numbers followed by a
-. For example010-about.mdor in case of a file in a directory100-examples/010-about.mdwill be replaced withabout.mdandexamples/about.md.
You can define your own pattern in the config. Removal of a prefix can be disabled by settingremove_reto an empty string. -
Instead of specifying the entire relative path in a link, include only the part of the destination that you are certain will remain unique. From here on it will be called a short link.
This plugin will replace a short link with the relative path to the page file it points to. Normal MkDocs processing will transform the Markdown link with relative path to HTML. -
In case there is a short link on a page but there are multiple files in the whole docs directory that match the path of that short link a warning will be logged. If configuration setting
warn_lessis true, a warning is not logged if there is a single destination in the same directory branch of the page that contains the short link.So it is ok to have a link
[About](about.md)on a page if fileabout.mdis located somewhere in a subdirectory of the directory where the page with the short link is located. Even if there are otherabout.mdfiles in other directory branches, as long as they can only be reached by going higher up in the directory tree (do a ../ first).
Configuration
The following configuration options can be set in mkdocs.yml. Values shown here are the default.
plugins:
- awesome-autolinks:
remove_re: '^[0-9]+-'
warn_less: false
warn_on_no_use: true
ignore_dirs:
- css
- fonts
- img
- js
- search
- javascripts
- assets/javascripts
debug: false
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_awesome_autolinks-1.0.0.tar.gz.
File metadata
- Download URL: mkdocs_awesome_autolinks-1.0.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e7437822cdaacf1a6b501d2a4c5cb30c7e9a7950892fecf4d59342bd76ccbfc
|
|
| MD5 |
4f3e92e2de8273da214d81ed69cde1c4
|
|
| BLAKE2b-256 |
2967cd854c2e493f9d7123a1eccd610ad98c0c42e930023953b24503b03a89c7
|
Provenance
The following attestation bundles were made for mkdocs_awesome_autolinks-1.0.0.tar.gz:
Publisher:
publish.yml on Johan-EU/mkdocs-awesome-autolinks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_awesome_autolinks-1.0.0.tar.gz -
Subject digest:
4e7437822cdaacf1a6b501d2a4c5cb30c7e9a7950892fecf4d59342bd76ccbfc - Sigstore transparency entry: 185549576
- Sigstore integration time:
-
Permalink:
Johan-EU/mkdocs-awesome-autolinks@2f1b0ac8f1258789c928ed64a566e4e758f00a2b -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Johan-EU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2f1b0ac8f1258789c928ed64a566e4e758f00a2b -
Trigger Event:
release
-
Statement type:
File details
Details for the file mkdocs_awesome_autolinks-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_awesome_autolinks-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
effd82f313100a0e3bb1d7afee27cff3c70eed7e5546d63c2b9f32f1bf6d69b9
|
|
| MD5 |
b1784dade51152bf77fde95ce18fb914
|
|
| BLAKE2b-256 |
6df221be45a05df4b9f7921392da9db851ed989bccd3a0094358510f56af2530
|
Provenance
The following attestation bundles were made for mkdocs_awesome_autolinks-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Johan-EU/mkdocs-awesome-autolinks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_awesome_autolinks-1.0.0-py3-none-any.whl -
Subject digest:
effd82f313100a0e3bb1d7afee27cff3c70eed7e5546d63c2b9f32f1bf6d69b9 - Sigstore transparency entry: 185549581
- Sigstore integration time:
-
Permalink:
Johan-EU/mkdocs-awesome-autolinks@2f1b0ac8f1258789c928ed64a566e4e758f00a2b -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Johan-EU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2f1b0ac8f1258789c928ed64a566e4e758f00a2b -
Trigger Event:
release
-
Statement type: