Client side redirects from # #3764
Replies: 2 comments 6 replies
-
I agree that this is definitely a use case and I was hoping that support would be added to mkdocs-redirects, which hasn't happened yet. What's missing is some client-side JavaScript that analyzes the URL, checks if there's a valid anchor mapping, and then redirects to that anchor or redirects to the page if the anchor doesn't match. Furthermore, anchors should be passed through as a fallback. It shouldn't be too hard, but I'm not sure it's worth the trouble, as mkdocs-redirects was last updated 11 months ago and doesn't look active. Furthermore, in mkdocs/mkdocs-redirects#32 (comment) it's stated that the original developer left the company and @oprypin said he wanted to take ownership, so maybe he has some ideas how to proceed here. |
Beta Was this translation helpful? Give feedback.
-
Swinging back to this in case anyone else is searching for the same. After making a nuisance of myself on the Netlify forums trying to find workarounds, and some strenuous copy-pasting, I've reluctantly fallen back on the hit 404 -> then redirect option: Client-side redirects using the 404 pageCreate an overrides directory, add a 404.html, and add the following:
Limitations:
The 'better' optionHonestly, at the moment, the best option might be to just do page-to-page and accept anyone relying on particular anchor tags lands up in roughly the right place, rather than precisely where they want to be. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I am hoping to move my new employer to MkDocs + Material, but the main sticking point is client side redirects.
I found Mkdocs redirects, but it doesn't support URLs with '#' in (there's an open issue about it from Martin) That issue led me to mkdocs gen files, which looks super useful - and let's you redirect TO a URL with a '#', but I can't figure out how to redirect FROM one (have opened an issue)
I'm asking here as well as I suspect it's a larger audience and I'd like to hear any way people have solved this.
Any help greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions