Migrating from VuePress to VitePress

What
VuePress and VitePress are Vue-based static site generators which take Markdown content and export performant multipage sites. Their default themes are designed with software documentation in mind but are a good fit for any chapter-based — think Docusaurus, Starlight, etc. With custom themes, they are reasonable options for any static site — think Astro (Vue and others), Nuxt (Vue), Eleventy (can do Vue, with zero hand holding, with @11ty/is-land), Next (React).
VuePress came first, in 2018.[1] VuePress stable 1.x saw active development for about a year.[2] Late 2020 saw the first VuePress v2.[3] By then, work was well underway for VitePress[4]. At the time, VitePress was expected to be released as VuePress v3.[5] That’s not what happened: the two stayed separate. Today, VitePress is supported by the Vue.js team, and VuePress is supported by the community.[6]
Why
VuePress was my go-to software documentation framework for years. Since VitePress’s initial stable release six months prior to this writing, I’ve been migrating VuePress sites to VitePress.
The VitePress docs state
VitePress is the spiritual successor of VuePress…VitePress provides significantly better DX, better production performance, a more polished default theme, and a more flexible customization API.[7]
For me, a major benefit is site search.
VuePress supports its own search, which they warn could be slow. VuePress also supports using Algolia’s DocSearch or standard Algolia. The DocSearch team only approves sites which are “publicly available developer documentation or a technical blog”. The steps to use standard Algolia with VuePress are not well documented, and the final result is a high-friction DX; I’ve written up the process in Algolia search in VuePress without joining DocSearch.
VitePress has out-of-the-box support for minisearch. Enabling it requires just one line of code, with no additional work needed when updating site content. That’s a huge improvement over what I’d been doing with standard Algolia in VuePress. (Read more in VitePress’s local search docs.)
How
Heads up
In the following steps, I refer to paths starting with .vuepress and .vitepress. Adjust those to your setup.
It’s not uncommon to nest VuePress or VitePress in a docs directory. In that case, use docs/.vuepress instead of .vuepress and/or docs/.vitepress instead of .vitepress, or cd docs and then run the commands as I’ve written them.
These are the steps I take:
-
Remove VuePress-specific dependencies, including anything under the
@vuepressscope.shell<package manager> remove vue vuepress # and possibly `@vuepress/bundler-vite`, `@vuepress/theme-default`, "`@vuepress/plugin-blog`, etc. -
Add VitePress dependencies
shell<package manager> add -D vitepress -
Initialize VitePress.
When asked if you want to add package scripts, select yes.
If you customized the VuePress site at all (for example, with
vuepress/styles/index.scss), when asked whether you want to customize the theme select “Default Theme + Customization”.shellbun vitepress init # or npx vitepress init # N.B: not `npm` # or pnpm vitepress init # or yarn vitepress init -
If you initialized VitePress with “Default Theme + Customization”, install
vue:shell<package manager> add -D vue -
Delete VitePress’s sample Markdown files
Tip
If you’re new to VitePress, you might want to read through these files first.
shellrm api-examples.md markdown-examples.mdand remove the references to
api-examples.mdandmarkdown-examples.mdfrom.vitepress/config.(js|ts). -
Comment out the reference in
.vitepress/theme/index.(js|ts)tostyle.css. -
Update
.gitignoreVuePress’s cache directory is dot-prefixed. VitePress’s is not. VitePress doesn’t have a
tempdirectory. The change will be something likeshell.vuepress/.temp .vuepress/.cache .vuepress/dist .vitepress/cache .vitepress/dist -
Move the
publicdirectory to the docs rootshellmv .vuepress/public public -
Delete VuePress artifacts
shellrm -rf .vuepress/.cache .vuepress/.temp .vuepress/dist -
Move CSS files. ⚠️ Note that VitePress will automatically discover them. Get to that later.
shellmv .vuepress/styles/* .vitepress/theme -
Move components, etc., from
.vuepressto.vitepress. For example, that might look likeshellmv .vuepress/components .vitepress/components mv .vuepress/stores .vitepress/stores mv .vuepress/utilities .vitepress/utilities -
Migrate
.vuepress/client.(js|ts)content to.vitepress/theme/index.(js|ts). For example, move everything in@vuepress/client’sdefineClientConfig.enhanceto the VitePress theme’senhanceApp, like so.vuepress/client.tstsimport { defineClientConfig } from "@vuepress/client"; // … import MyComponent from "./components/MyComponent.vue"; // … export default defineClientConfig({ enhance({ app }) { // … app.component("MyComponent", MyComponent); // … }, });would become this
.vitepress/theme/index.tsts// … import MyComponent from "../components/MyComponent.vue"; export default { // … enhanceApp({ app }) { // … app.component("MyComponent", MyComponent); // … }, // … }; -
Migrate the config. Some things are the same, some are different.
VuePress docs: VuePress site config, VuePress theme config
VitePress docs: VitePress site config, VitePress theme config
The gotchas I’ve encountered:
-
VuePress’s
markdown.links.externalAttrsis VitePress’smarkdown.externalLinks. -
In VuePress, to prevent external links in Markdown from opening in a new tab you do
.vuepress/config.tsts// … markdown: { links: { externalAttrs: { target: "", }, }, }, // …In VitePress, do
.vuepress/config.tsts// … markdown: { externalLinks: { target: "_self", }, }, // … -
VuePress’s
themeConfig.navbaris VitePress’sthemeConfig.nav. -
VuePress’s
themeConfig.sidebarsupports URL strings and interpolating the item text from the file content, like this.vuepress/config.tsts// … sidebar: [ // … 'file.md', // … ], // …VitePress’s linked sidebar items must be objects with
linkand an explicittext, like this:.vuepress/config.tsts// … sidebar: [ // … { link: 'file.md' text: 'The File', }, // … ], // … -
VuePress’s
themeConfig.sidebargroups are underchildren. VuePress’s are underitems.
-
-
Start dev mode:
shell<package manager> run docs:dev -
Deal with any remaining
.vuepressfiles. -
Delete the
.vuepressdirectory. -
If you moved any stylesheets into
.vitepress,-
Port SCSS to CSS, and rename files to use the extension
cssnotscss. -
Import them in
.vitepress/theme/index.(js|ts):vitepress/theme/index.tstsimport "./<the file name>.css"; -
Referring to
.vitepress/theme/style.cssand inspecting in the browser, figure out which of your custom VuePress styles you want to use in VitePress, and how to apply them.
-
-
Delete VitePress’s sample CSS
shellrm .vitepress/theme/style.css
Footnotes
On the web
Also In This Series
-
-
Styling VitePress with Tailwind

Configure Tailwind as a PostCSS plugin to use it in VitePress Markdown, JS/TS, and Vue files
Articles You Might Enjoy
-
SSG Astro with Headless Craft CMS Content Fetched At Build Time Or Cached In Advance

Astro on the front, Craft on the back. Craft can be local only, and the build environment doesn't have to connect to the CMS.
-
Add high-performance search to static sites with PageFind

The concise guide to using Pagefind for your static site’s search functionality.
-
From Stimulus to web components

Stimulus experience translates to native custom elements. What does it take to make a custom element with Stimulus features?





