0

I have a Vitepress 1.0.0-alpha.40 project with the following configuration

import { defineConfig } from 'vitepress'

export default defineConfig({
    base: './',
    outDir: '../dist',
    themeConfig: {
        sidebar: [
            {
                text: 'Configuration',
                collapsible: true,
                items: [
                    {
                        text: 'Foo',
                        link: '/configuration/foo'
                    }
                ]
            },
            {
                text: 'Deployment',
                collapsible: true,
                items: [
                    {
                        text: 'Bar',
                        link: '/deployment/bar'
                    }
                ]
            }
        ]
    }
})

and the following folder structure

.
└── docs
    ├── .vitepress
    │   └── config.ts
    ├── configuration
    │   └── foo.md
    ├── deployment
    │    └── bar.md
    └── index.md

When running the application on http://localhost:5173/ I see the following

enter image description here

When clicking on the sidebar link Foo it works fine, the router navigates to

http://localhost:5173/configuration/foo.html

But when I now click Bar the router navigates to

http://localhost:5173/configuration/deployment/bar.html

which is wrong. The expected url would be

http://localhost:5173/deployment/bar.html

It seems it always adds the previous segment e.g. "/configuration".

Does someone know how to fix this behaviour?

baitendbidz
  • 187
  • 3
  • 19

1 Answers1

0

This happened because you put ./ in the base configuration.

Either put something other like / (default) or /base/.

Or remove the config altogether.

Pierre Said
  • 3,660
  • 1
  • 16
  • 28
  • I need to use a relative path ( https://vitejs.dev/config/shared-options.html#base ) because the Apache deployment server is not able to deal with an absolute path – baitendbidz Jan 20 '23 at 21:32
  • At which level is it not able to handle an aboslute path ? – Pierre Said Jan 20 '23 at 22:30
  • Also do you need to need a complex server with apache for this site. As this can be easily deployed with any static site provider as netlify, render.com, cloudflare or vercel – Pierre Said Jan 20 '23 at 22:31
  • When building a Vue app without a relative path the .html file has `` but the Apache server needs `` . I do not own the deployment infrastructure – baitendbidz Jan 21 '23 at 08:09