Skip to content
On this page

Getting Started

Try It Online

You can try VitePress Blog directly in your browser on StackBlitz.

Installation

Prerequisites

VitePress Blog can be used on its own, or be installed into an existing project. You need to install both vitepress and @jcamp/vitepress-blog-theme In both cases, you can install it with:

sh
$ npm install -D vitepress @jcamp/vitepress-blog-theme
sh
$ pnpm add -D vitepress @jcamp/vitepress-blog-theme
sh
$ yarn add -D vitepress @jcamp/vitepress-blog-theme
Getting missing peer deps warnings?

If using PNPM, you will notice a missing peer warning for @docsearch/js. This does not prevent VitePress from working. If you wish to suppress this warning, add the following to your package.json:

json
"pnpm": {
  "peerDependencyRules": {
    "ignoreMissing": [
      "@algolia/client-search"
    ]
  }
}

Start Repo

We have a starter template repo available on GitHub:

https://github.com/jcamp-code/starter-vitepress-blog

You can click the large green Use This Template button GitHub or use degit to get started:

sh
$ npx degit https://github.com/jcamp-code/starter-vitepress-blog
sh
$ pnpm exec https://github.com/jcamp-code/starter-vitepress-blog

Setup Wizard

We are still working on the init wizard

Vue as Peer Dependency

If you intend to perform customization that uses Vue components or APIs, you should also explicitly install vue as a peer dependency.

Posts and Authors

Files stored under /blog/posts are converted to blog posts, while files stored under /blog/authors are treated as author details. These paths can be configured as needed.

You can also set a default author if you don't want to specify an author for every post, for exmple, if there is only one author.

Categories and Tags

The category is a top level item, and is optional. For example, this can be articles, documentation, tutorials, whatever you want it to be.

Tags are specified on each post and each post can have as many tags as you want.

The Config File

The config file (.vitepress/config.js) allows you to customize various aspects of your VitePress site, with the most basic options being the title and description of the site:

js
// .vitepress/config.js
export default {
  // site-level options
  title: 'VitePress',
  description: 'Just playing around.',

  themeConfig: {
    // theme-level options
  },
}

Up and Running

The tool should have also injected the following npm scripts to your package.json if you allowed it to do so during the setup process:

json
{
  ...
  "scripts": {
    "docs:dev": "vitepress dev docs",
    "docs:build": "vitepress build docs",
    "docs:preview": "vitepress preview docs"
  },
  ...
}

The docs:dev script will start a local dev server with instant hot updates. Run it with the following command:

sh
$ npm run docs:dev
sh
$ pnpm run docs:dev
sh
$ yarn docs:dev

Instead of npm scripts, you can also invoke VitePress directly with:

sh
$ npx vitepress dev docs
sh
$ pnpm exec vitepress dev docs

The dev server should be running at http://localhost:5173. Visit the URL in your browser to see your new site in action!

What's Next?

  • For full details of VitePress and its deployment, please refer to the VitePress Guide