Skip to content

Option to prefix absolute links with sub-page or turn them relative. #3308

@Andre601

Description

@Andre601

Problem

Using absolute URLs may not work, if the final page is on a sub-page. For example, if a page is hosted on https://example.com/blog will an absolute URL such as /foo/bar result in a link pointing to https://example.com/foo/bar, breaking sites.

The idea

An option should be added which would do either one of two things:

  • Prepend the sub-page to the absolute URLs, so that /foo/bar turns into /blog/foo/bar
  • Turn the absolute path into a relative path, meaning that the link /foo/bar located in /docs/example/index.md becomes ../foo/bar

Why?

The usage of relative URLs can be tedious. While text editors such as VSCode may offer QoL stuff such as displaying folders and files when creating a relative path, is that feature not available for everyone obviously.

In addition can a relative URL also cause issues when you move pages around, as it would then require to edit any relative URL in all moved pages to match the new path (or edit relative paths pointing to the moved pages/files).

With having MkDocs deal with it, I could simply provide /assets/img/cat.png and no matter where I move the page, the link would properly resolve to the right relative path (or absolute path if the prepending option is used) reducing headaches when trying to resolve relative paths...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions