Skip to content

Links in the Nav bar do not support rewrites #4364

Open
@ThePlenkov

Description

@ThePlenkov

Describe the bug

I have a /guide path redirecting to one of first pages like guide/product and it works if I click action button, feature button or just change the route.

However it doesn't work if I click a nav button

Reproduction

import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({ 
  rewrites: {
    '/guide': "guide/intro"
  },
  themeConfig: {
    // https://vitepress.dev/reference/default-theme-config
    nav: [
      { text: 'Home', link: '/' },
      { text: 'Guide', link: '/guide' }
    ],

    sidebar: {

      "/guide": [
        {
          text: 'Introduction',
          items: [
            { text: 'Intro?', link: '/guide/intro/' },
          ]
        },
]

    }
  }

)

Expected behavior

I expect that clicking a link in the nav would handle it same way as it handles it everywhere else on the site

System Info

System:
    OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (2) x64 12th Gen Intel(R) Core(TM) i7-1265U
    Memory: 7.76 GB / 11.69 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 22.9.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.8.3 - /usr/local/bin/npm
    pnpm: 9.12.1 - /usr/local/share/npm-global/bin/pnpm
  npmPackages:
    vitepress: ^1.5.0 => 1.5.0

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions