mkdocs / mkdocs-redirects

Open source plugin for Mkdocs page redirects
MIT License
176 stars 25 forks source link

Do redirects support header links? #20

Closed Andre601 closed 3 years ago

Andre601 commented 3 years ago

I was wondering, if the redirects created by this plugin do support header links.

For example: Would a configuration that redirects old_page.md to new_page.md make https://example.com/old_page#header redirect to https://example.com/new_page#header?

From my basic testing does this not seem to be the case and I'm not sure if that is doable with redirects.

Andre601 commented 3 years ago

Actually nevermind. There was a typo in my test and it now works. Sorry to bother.

DominikaK commented 2 years ago

While this has been reported as resolved, I am also encountering this issue at the moment, using mkdocs-redirects==1.0.4.

A redirect formulated as 'page_one.md': 'page_two.md#' correctly redirects from page_one.md to page_two.md. However, the following configuration is ignored:

nav:
    - 'Documentation': 'index.md'
    - 'Page one': 'page_one.md'
    - 'Page two': 'page_two.md'

plugins:
    - redirects:
        redirect_maps:
            'page_one.md#heading': 'page_two.md#heading'

When running mkdocs serve, the following error message is displayed:

WARNING  -  redirects plugin: 'page_one.md#heading' is not a valid markdown file!
WARNING  -  Redirect target 'page_two.md#heading' does not exist!
Andre601 commented 2 years ago

While this has been reported as resolved, I am also encountering this issue at the moment, using mkdocs-redirects==1.0.4.

A redirect formulated as 'page_one.md': 'page_two.md#' correctly redirects from page_one.md to page_two.md. However, the following configuration is ignored:

nav:
    - 'Documentation': 'index.md'
    - 'Page one': 'page_one.md'
    - 'Page two': 'page_two.md'

plugins:
    - redirects:
        redirect_maps:
            'page_one.md#heading': 'page_two.md#heading'

When running mkdocs serve, the following error message is displayed:

WARNING  -  redirects plugin: 'page_one.md#heading' is not a valid markdown file!
WARNING  -  Redirect target 'page_two.md#heading' does not exist!

Don't add headers in the redirects. Just use the normal pages. Any redirects added to the URL will be forwarded to the redirect itself... That's exactly what I mentioned in my issue.

So in your case 'page_one.md': 'page_two.md' would redirect page_one#some-header to page_two#some-header

DominikaK commented 2 years ago

Thanks for the advice. Do you know, then, if it's possible to create a redirect between two headings? Say, I changed heading "First heading" to "Second heading". 'page_one.md#first-heading': 'page_two.md#second-heading' will not function, but maybe you've found some other way to handle it?