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

Plugin does not work properly when site is hosted in a subdirectory #1

Closed
remyzandwijk opened this issue Jun 20, 2022 · 1 comment
Closed
Assignees

Comments

@remyzandwijk
Copy link

Hi @EddyLuten,

Thanks for writing this plugin! I ran some tests with it and all seemed fine while hosting the MkDocs site files from the root of the website, e.g. site_url: https://www.example.com in mkdocs.yml. However, I found that the plugin does not work properly when hosting the files in a subdirectory of the site. E.g. site_url: https://www.example.com/subdir.

The problem lies in the fact that the plugin generates absolute links. Meaning: the category links on the category index page are always prefixed with /categories; it does not take the subdir in account. The same is true for the category pages (which contain links to the pages on which the category is used on) and the 'normal' pages, on which the categories of that page are listed.

The MkDocs documentation states that absolute paths with links are not officially supported (source) and that relative paths are to be used.

I prepared a small patch which makes the plugin generate relative links. Could you please take a look at it and share your thoughts? Thanks!

-Remy

plugin.py.patch.txt

@EddyLuten EddyLuten self-assigned this Jul 2, 2022
@EddyLuten
Copy link
Owner

Hi @rpmzandwijk, thanks so much for the patch, and sorry for the late response! I'm testing your changes on my wiki, and they work great. I did have to modify one line slightly to read:

lambda p: f"- [{p['title']}](../../{p['url']}/)",

Notice the trailing slash. If you stick your main index.md page into a category, MkDocs would complain about the path of .. being invalid. Adding a trailing slash fixed that.

I also replaced the added for-loop with the already existing map() function, but with your modified code added in.

I will push the changes out in the next patch release, 0.2.1, so keep an eye out for that later today. Thanks again for the changes; it's nice to know that real humans other than myself are using the plugin!

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