Quickly generate static websites using VitePress. Supports installing dependencies, initializing projects, local preview, building, and deployment.
When users need to create a static website, follow the process below:
First, confirm that the user has Node.js installed:
bash
node -v
npm -v
If not installed, prompt the user to install Node.js first (v18+ recommended).
bash
mkdir <project-name>
cd <project-name>
npm init -y
bash
npm add -D vitepress
Create the basic directory structure:
text
<project-name>/
├── docs/
│ ├── .vitepress/
│ │ └── config.mts
│ ├── index.md
│ └── guide/
│ └── getting-started.md
├── package.json
└── README.md
Add the following to package.json:
json
{
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
}
}
bash
npm run docs:dev
Default access: http://localhost:5173
bash
npm run docs:build
Output directory: docs/.vitepress/dist/
For detailed configuration options, see references/config-guide.md
For custom themes and styles, see references/theme-customization.md
For deployment to different platforms, see references/deployment.md
CommandDescriptionnpm run docs:devStart local development servernpm run docs:buildBuild production versionnpm run docs:previewPreview build results
docs/.vitepress/dist/ directory.mts, .ts, .mjs, .js formats