Skip to content

Make a filter similar to MkDocs' url filter #199

Answered by Andre601
Andre601 asked this question in Q&A
Discussion options

You must be logged in to vote

Managed to get a working filter using this:

from mkdocs.utils import normalize_url

def define_env(env):

    @env.filter
    def url(path: str):
        return normalize_url(path=path, page=env.page)

Allows me to have {{ page.url | url }}

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Andre601
Comment options

@fralau
Comment options

@Andre601
Comment options

Answer selected by Andre601
@SuibianP
Comment options

@fralau
Comment options

@SuibianP
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants