mkdocs / mkdocs-redirects

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

add 'allow_html_redirect' configuration option to avoid printing warning when redirecting .html URLs #50

Open boegel opened 1 year ago

boegel commented 1 year ago

I'm porting documentation that currently uses Sphinx + .rst to MkDocs + md, and I would like to ensure that redirects are in place for old URLs like https://docs.easybuild.io/en/latest/Configuration.html.

To achieve this, I'm using mkdocs-redirects, as follows in mkdocs.yml:

plugins:
  - redirects:
      redirect_maps:
        en/latest/Configuration.html: configuring_easybuild.md

That's working fine (see https://easybuilders.github.io/easybuild-docs/en/latest/Configuration.html which correctly redirects), but mkdocs-redirects is logging warnings when .html URLs are redirected:

WARNING  -  redirects plugin: 'en/latest/Configuration.html' is not a valid markdown file!

That's annoying, since I would like to use mkdocs build --strict in CI to test changes to our documentation, and that exits with a non-zero exit code as soon there as any warnings.

The changes being proposed here allow configuring mkdocs-redirects with allow_html_redirects to silence the warning:

plugins:
  - redirects:
      allow_html_redirect: True
      redirect_maps:
        en/latest/Configuration.html: configuring_easybuild.md
boegel commented 1 year ago

I'm happy to make the extra effort in this PR to update the README file with a new section that documents this feature, and to implement a test to verify that the feature works as expected, but I would like to get some feedback first on whether this feature would be accepted for inclusing in mkdocs-redirects before doing so.

oprypin commented 1 year ago

Just a few days ago I was thinking that something like this would be good, because indeed, the current setup assumes you're migrating from an exact same MkDocs setup (even down to use_directory_urls). And I actually think this shouldn't even be behind a config. But I'll need to carefully look at the code myself first. It would be good to have this as an issue instead, to clearly define what use case we're solving. Though I see that in the description of your pull request you do define the use case very well, definitely thanks for that!

boegel commented 1 year ago

@oprypin Thanks for the feedback, I've opened an issue for this at #51

jrappen commented 1 year ago

@oprypin what's the current status here?