Skip to content

Localized blog category names #7047

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

You must be logged in to vote

Finally, I found a solution to do it with a hook:

def on_pre_page(page, config, files):
    titles = {
        "some_slug/": "Custom Title 1",
        "another_slug/": "Custom Title 2",
    }
    if page.url in titles:
        page.title = titles[page.url]
    return page

def on_page_markdown(markdown, page, config, files):
    replacements = [
        ("# some_slug", "# Custom Title 1"),
        ("# another_slug", "# Custom Title 2"),
    ]
    for old, new in replacements:
        markdown = markdown.replace(old, new)
    return markdown

Will this solution have any side effects or is it safe?

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@dragomano
Comment options

@alexvoss
Comment options

alexvoss Apr 15, 2024
Collaborator Sponsor

@dragomano
Comment options

Answer selected by dragomano
@alexvoss
Comment options

alexvoss Apr 16, 2024
Collaborator Sponsor

@alexvoss
Comment options

alexvoss Apr 16, 2024
Collaborator Sponsor

@dragomano
Comment options

@alexvoss
Comment options

alexvoss Apr 16, 2024
Collaborator Sponsor

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