Development FAQ
Frequently asked questions about VitePress development workflow.
Getting Started
Q: How do I create a new VitePress project?
A: Use the following commands:
bash
npm create vitepress@latest my-docs
cd my-docs
npm install
npm run docs:dev
Q: What's the recommended project structure?
A: Basic structure:
docs/
├── .vitepress/
│ └── config.js
├── index.md
├── guide/
│ └── index.md
└── package.json
Configuration
Q: How do I customize the theme?
A: You can:
- Use theme configuration options
- Override CSS variables
- Create custom components
- Build a custom theme
Q: How do I add a custom domain?
A: Steps:
- Add CNAME file to public directory
- Configure your DNS settings
- Update base URL in config
- Deploy your site
Content Creation
Q: How do I add navigation menus?
A: Configure in .vitepress/config.js
:
javascript
export default {
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' }
]
}
}
Q: How do I create a sidebar?
A: Add sidebar configuration:
javascript
export default {
themeConfig: {
sidebar: {
'/guide/': [
{
text: 'Getting Started',
items: [
{ text: 'Introduction', link: '/guide/' },
{ text: 'Installation', link: '/guide/installation' }
]
}
]
}
}
}
Customization
Q: Can I use custom Vue components?
A: Yes, you can:
- Create components in
.vitepress/components/
- Register them globally
- Use them in markdown files
Q: How do I add custom CSS?
A: Methods:
- Add CSS to
.vitepress/theme/style.css
- Import CSS in custom theme
- Use CSS variables for theming
Deployment
Q: How do I deploy to GitHub Pages?
A: Steps:
- Configure base URL
- Set up GitHub Actions workflow
- Enable GitHub Pages
- Push your changes
Q: Can I deploy to other platforms?
A: Yes, VitePress works with:
- Netlify
- Vercel
- AWS S3
- Azure Static Web Apps
- Any static hosting service
Troubleshooting
Q: My changes are not showing up
A: Try:
- Hard refresh browser (Ctrl+F5)
- Clear browser cache
- Restart dev server
- Check for syntax errors
Q: How do I debug build issues?
A: Use these commands:
bash
npm run docs:build --debug
npm run docs:preview