Skip to content

mkdocs_nype.plugins.custom_redirects.plugin

Synopsis

MkDocs plugin made to replace the HTML template used in the redirects plugin.

This plugin was formerly a hook:

MIT License 2024 Kamil Krzyśków (HRY) for Nype (npe.cm)

PLUGIN_NAME

PLUGIN_NAME = 'custom_redirects'

LOG

LOG: PrefixedLogger = PrefixedLogger(PLUGIN_NAME, getLogger(f'mkdocs.plugins.{PLUGIN_NAME}'))

HTML_TEMPLATE

HTML_TEMPLATE = '\n<!doctype html>\n<html>\n  <head>\n    <meta charset="utf-8" />\n    <meta name="viewport" content="width=device-width,initial-scale=1" />\n    <title>{{ config.site_name }}</title>\n    <link rel="canonical" href="{url}" />\n    <meta name="robots" content="index, follow">\n    <noscript>\n      <meta http-equiv="refresh" content="0;url={url}" />\n    </noscript>\n    <script>\n      window.location.replace([\n        "{url}",\n        window.location.search,\n        window.location.hash\n      ].join(""))\n    </script>\n  </head>\n  <body></body>\n</html>\n'

CustomRedirectsPlugin

Bases: BasePlugin[CustomRedirectsConfig]

on_config

on_config(config: MkDocsConfig)

write_html_wrapper

write_html_wrapper(func, config: MkDocsConfig)

By default the redirect links are relative, which might not be so good for SEO