Getting Started
This chapter will guide you through creating a VitePress site from scratch.
Prerequisites
- Node.js version 18 or higher.
- Terminal and code editor (such as VSCode).
Initialize Project
-
Create and enter a new directory
-
Initialize npm project
-
Install VitePress
-
Run initialization wizard
VitePress provides a convenient command-line tool to help you set up the basic structure.
The wizard will ask a few questions, such as your documentation root directory, site title, and description. Answer according to your needs.
Project Structure
After initialization, your project structure will look roughly like this:
docs: Where all Markdown source files and VitePress configuration are stored..vitepress: The "heart" of VitePress, containing configuration files, themes, and custom components.config.js: The core configuration file for the site.
Start Development Server
VitePress automatically adds some scripts to package.json.
-
Start development server
-
Visit the site
Open your browser and visit the URL displayed in the command line (usually
http://localhost:5173).
Now you should see your VitePress site running! Any changes you make to .md files in the docs directory will be instantly reflected in the browser through hot module replacement (HMR), without needing to refresh the page.
Build Static Site
When you're ready to deploy your site, you can run the following command:
This generates the final static files in the .vitepress/dist directory, which you can deploy to any static hosting service.