Skip to main content

MkDocs plugin to create /<ID>/ redirects from front-matter IDs

Project description

mkdocs-vwidalias

mkdocs-vwidalias is a tiny MkDocs plugin that generates root-level alias URLs based on a page’s front-matter ID.

  • Front-matter:
  ---
  id: SV-OVERVIEW
  title: Services Overview
  ---
  • Build output:
  site/SV-OVERVIEW/index.html
  • When opened, it redirects to the canonical page (by default appending #SV-OVERVIEW):
  /path/to/page/#SV-OVERVIEW

Now you can share short links like:

https://yoursite/SV-OVERVIEW/

Features

  • Reads a configurable front-matter field (id_field, default id)
  • Emits alias pages at /<ID>/index.html (or /prefix/<ID>/index.html)
  • Optional alias_prefix (e.g., /id/SV-OVERVIEW/)
  • Optional #ID appended to the target (append_hash: true)
  • Duplicate ID detection (warn or fail)
  • Verbose logging for easy debugging

Install

pip install mkdocs-vwidalias

Configure (mkdocs.yml)

plugins:
  - search
  - mkdocs_vwidalias:
      id_field: "id"          # front-matter key
      alias_prefix: ""        # "" => /<ID>/ ; "id" => /id/<ID>/
      append_hash: true       # append '#<ID>' to target URL
      fail_on_duplicate: false

Author pages

---
id: SV-OVERVIEW
title: Services Overview
---

# Services Overview
Hello!

Build the site and you’ll get:

  • Alias: site/SV-OVERVIEW/index.html
  • Redirect target: /services/overview/#SV-OVERVIEW (example)

Debugging

Run with verbose logs:

mkdocs build -v
# or
mkdocs serve -v

You should see:

[mkdocs_vwidalias] Aliases to emit: 1
[mkdocs_vwidalias] Emitted 1 alias pages. Prefix=''

Notes

  • Keep id values unique across pages.
  • Works best with MkDocs pretty URLs (default).
  • Alias pages include a canonical link to the target for SEO.

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-vwidalias-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file mkdocs-vwidalias-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocs-vwidalias-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.32.5 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for mkdocs-vwidalias-0.1.0.tar.gz
Algorithm Hash digest
SHA256 07dc4ed95cfa1d97110e21786e0b4af6c2a57e7bff2e97cb41271b7d00420214
MD5 383b4f3c1bad0a161bb1b665e8bed21f
BLAKE2b-256 4bbbd01c3cac93a1a91c3f35ab04f8d58379eeb2bb0df7823f9921139507ac43

See more details on using hashes here.

Supported by

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