Skip to main content

Automatically link across pages in MkDocs.

Project description

mkdocs-autorefs

ci documentation pypi version conda version gitpod gitter

Automatically link across pages in MkDocs.

Installation

With pip:

python3 -m pip install mkdocs-autorefs

Usage

# mkdocs.yml
plugins:
  - search
  - autorefs

In one of your Markdown files (e.g. doc1.md) create some headings:

## Hello, world!

## Another heading

Link to [Hello, World!](#hello-world) on the same page.

This is a normal link to an anchor. MkDocs generates anchors for each heading, and they can always be used to link to something, either within the same page (as shown here) or by specifying the path of the other page.

But with this plugin, you can link to a heading from any other page on the site without needing to know the path of either of the pages, just the heading title itself.
Let's create another Markdown page to try this, subdir/doc2.md:

We can [link to that heading][hello-world] from another page too.

This works the same as [a normal link to that heading](../doc1.md#hello-world).

Linking to a heading without needing to know the destination page can be useful if specifying that path is cumbersome, e.g. when the pages have deeply nested paths, are far apart, or are moved around frequently. And the issue is somewhat exacerbated by the fact that MkDocs supports only relative links between pages.

Note that this plugin's behavior is undefined when trying to link to a heading title that appears several times throughout the site. Currently it arbitrarily chooses one of the pages.

Requirements

mkdocs-autorefs requires Python 3.7 or above.

To install Python 3.7, I recommend using pyenv.
# install pyenv
git clone https://github.com/pyenv/pyenv ~/.pyenv

# setup pyenv (you should also put these three lines in .bashrc or similar)
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"

# install Python 3.7
pyenv install 3.7.12

# make it available globally
pyenv global system 3.7.12

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-autorefs-0.4.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

mkdocs_autorefs-0.4.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-autorefs-0.4.1.tar.gz.

File metadata

  • Download URL: mkdocs-autorefs-0.4.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.11.2 pkginfo/1.8.1 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for mkdocs-autorefs-0.4.1.tar.gz
Algorithm Hash digest
SHA256 70748a7bd025f9ecd6d6feeba8ba63f8e891a1af55f48e366d6d6e78493aba84
MD5 ed023e94cf4867895cc5db9013e8898f
BLAKE2b-256 3b3f9531888bc92bafb1bffddca5d9240a7bae9a479d465528883b61808ef9d6

See more details on using hashes here.

File details

Details for the file mkdocs_autorefs-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_autorefs-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.11.2 pkginfo/1.8.1 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for mkdocs_autorefs-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2248a9501b29dc0cc8ba4c09f4f47ff121945f6ce33d760f145d6f89d313f5b
MD5 5b000b6d93938f057b66b67b4929c0da
BLAKE2b-256 fb5c6594400290df38f99bf8d9ef249387b56f4ad962667836266f6fe7da8597

See more details on using hashes here.

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