Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs redirects SEO bug #574

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/plugins/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ def on_page_markdown(markdown: str, page: Page, config: Config, files: Files) ->
return markdown


def on_pre_build(*_args, **_kwargs) -> None:
import mkdocs_redirects.plugin

# work around for very unfortunate bug in mkdocs-redirects:
# https://github.com/mkdocs/mkdocs-redirects/issues/65
mkdocs_redirects.plugin.HTML_TEMPLATE = """
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<link rel="canonical" href="{url}">
<!-- remove problematic tag here -->
<script>var anchor=window.location.hash.substr(1);location.href="{url}"+(anchor?"#"+anchor:"")</script>
<meta http-equiv="refresh" content="0; url={url}">
</head>
<body>
Redirecting...
</body>
</html>
"""


def check_documented_system_metrics(markdown: str, page: Page) -> str:
"""Check that all system metrics are documented.

Expand Down