Skip to content

Navigation: stay on page when switching languages #4835

@KusakabeShi

Description

@KusakabeShi

Contribution guidelines

I want to suggest an idea and checked that ...

  • ... to my best knowledge, my idea wouldn't break something for other users
  • ... the documentation does not mention anything about my idea
  • ... there are no open or closed issues that are related to my idea

Description

At this doc: https://squidfunk.github.io/mkdocs-material/setup/changing-the-language/#site-language-selector

This config always redirect to the homepage of another language:

extra:
  alternate:
    - name: English
      link: /en/ 
      lang: en
    - name: Deutsch
      link: /de/
      lang: de

Assume I'm in the https://example.com/de/customization page, click the "English" Button will be redirect to https://example.com/en/

Is it possible to set it like this

extra:
  alternate:
    - name: English
      link: /en/{nav.item} 
      lang: en
    - name: Deutsch
      link: /de/{nav.item}
      lang: de

So that I'm in the https://example.com/de/customization page, click the "English" Button will be redirect to https://example.com/en/customization page ?

Use Cases

Switching languages without leaving the current page.

I'm in the https://example.com/de/customization page, click the "English" Button will redirect to https://example.com/en/customization instead of https://example.com/en/

Screenshots / Mockups

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    change requestIssue requests a new feature or improvementresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions