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

Frontmatter-based redirects? #53

Open
Andre601 opened this issue Mar 2, 2023 · 1 comment
Open

Frontmatter-based redirects? #53

Andre601 opened this issue Mar 2, 2023 · 1 comment

Comments

@Andre601
Copy link

Andre601 commented Mar 2, 2023

Personally, I feel like it could be a nice feature to allow defining redirects in a file's yaml frontmatter.

As an example:

---
title: Title
description: Some page.

redirects:
  - old/location/index.md
---

# Title

Content

The benefits I see:

  • More organized. It's clear what old locations redirect to this page
  • Easier to edit. Move file, edit it vs. Move file, go to mkdocs.yml and edit it.

It's just a random idea that came to mind.

@kamilkrzyskow
Copy link

kamilkrzyskow commented Mar 2, 2023

I'll re-post the answer I've given here: mkdocs/mkdocs#3134

Here you go, https://github.com/kamilkrzyskow/gmc/commits/redirect-plugin?since=2023-02-24 that was my previous approach with another hook and old_nav meta list of old paths. However, I decided against it because moving a whole directory of files into another location requires modifying all of those files, and this just sullies the Git Blame imo, and is rather tedious to do (trust me, I took it till the end and modified 40 files by hand).

The idea came from the solution here squidfunk/mkdocs-material#3758 the difference here, which is VERY important is that the ContextID is static, possibly managed by some outside tooling and database, so the files can move however they want and the redirection will always point to the correct path, this doesn't go well with manually readjusting the "ContextID" equivalent after each move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants