| name | vitepress-clean-urls |
| description | With `cleanUrls: true`, nav links must NOT have `.html` extensions: |
| lastReviewed | 2026-04-30T00:00:00.000Z |
VitePress Clean URLs
The Problem
With cleanUrls: true, nav links must NOT have .html extensions:
export default {
cleanUrls: true
}
nav: [
{ text: 'Guide', link: '/guide/intro.html' }
]
[Read more](/guide/intro.html)
The Solution
When cleanUrls: true, use extensionless paths everywhere.
nav: [
{ text: 'Guide', link: '/guide/intro' }
]
sidebar: [
{ text: 'Introduction', link: '/guide/intro' }
]
<!-- In markdown files -->
[Read more](/guide/intro)
[See API](/api/methods)
Common Gotchas
| Pattern | cleanUrls: false | cleanUrls: true |
|---|
| Nav links | /guide.html | /guide |
| Sidebar links | /api/foo.html | /api/foo |
| Markdown links | [text](./page.html) | [text](./page) |
| External links | Unchanged | Unchanged |
Migration Script
const glob = require('glob');
const fs = require('fs');
glob.sync('docs/**/*.md').forEach(file => {
let content = fs.readFileSync(file, 'utf8');
content = content.replace(/\.html\)/g, ')');
content = content.replace(/\.html\]/g, ']');
fs.writeFileSync(file, content);
});
Verification
grep -rn '\.html[)\]]' docs/
When to Apply
- Enabling
cleanUrls: true in existing project
- Migrating from other static site generators
- Any VitePress project setup
Tags
vitepress urls configuration links