Modern documentation website for Yatra WordPress travel booking plugin, built with VitePress.
- Node.js: 18.0 or higher
- npm: 9.0 or higher
- Git: For version control
-
Clone the repository:
git clone https://github.com/mantrabrain/yatra.git cd yatra/app/public/yatra-docs -
Install dependencies:
npm install
-
Start development server:
npm run dev
-
Open browser: Navigate to
http://localhost:3000
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Serve production build
npm run serveyatra-docs/
βββ docs/ # Documentation source
β βββ .vitepress/ # VitePress configuration
β β βββ config.ts # Main configuration file
β β βββ theme/ # Custom theme (optional)
β βββ public/ # Static assets
β β βββ robots.txt # SEO robots file
β β βββ site.webmanifest # PWA manifest
β βββ guide/ # Documentation pages
β β βββ installation.md
β β βββ quick-start.md
β β βββ booking-settings.md
β β βββ payment-settings.md
β β βββ tour-booking.md
β β βββ ...
β βββ index.md # Homepage
βββ .github/ # GitHub workflows
β βββ workflows/
β βββ deploy.yml # Auto-deployment workflow
βββ netlify.toml # Netlify configuration
βββ package.json # Dependencies and scripts
βββ README.md # This file
-
Create new markdown file in
docs/guide/:touch docs/guide/your-new-page.md
-
Add frontmatter to the file:
--- title: Your New Page description: Page description for SEO prev: /guide/previous-page next: /guide/next-page ---
-
Add to sidebar in
docs/.vitepress/config.ts:{ text: 'Your Section', items: [ { text: 'Your New Page', link: '/guide/your-new-page' } ] }
Add custom CSS in docs/.vitepress/theme/style.css:
/* Custom styles for Yatra documentation */
.custom-class {
color: var(--vp-c-brand);
}-
Connect to Netlify:
- Push code to GitHub repository
- Connect Netlify to your GitHub account
- Select the
yatra-docsfolder
-
Configure build settings:
- Build command:
npm run build - Publish directory:
docs/.vitepress/dist - Node version: 18
- Build command:
-
Environment variables (if needed):
- Set any required environment variables in Netlify dashboard
-
Build the site:
npm run build
-
Deploy to Netlify:
npx netlify deploy --prod --dir=docs/.vitepress/dist
-
Enable GitHub Pages:
- Go to repository settings
- Enable GitHub Pages
- Select source:
gh-pagesbranch
-
Configure workflow:
- The
.github/workflows/deploy.ymlfile handles automatic deployment - Push to
mainbranch to trigger deployment
- The
-
Build the site:
npm run build
-
Deploy to GitHub Pages:
npm run build cd docs/.vitepress/dist git init git add . git commit -m "Deploy documentation" git branch -M gh-pages git push -f origin gh-pages
-
Install Vercel CLI:
npm i -g vercel
-
Deploy:
vercel --prod docs/.vitepress/dist
Main configuration is in docs/.vitepress/config.ts:
export default defineConfig({
title: 'Yatra Documentation',
description: 'Complete documentation for Yatra WordPress travel booking plugin',
theme: defaultTheme({
// Theme configuration
}),
// SEO and optimization settings
})The documentation includes comprehensive SEO optimization:
- Meta tags: Automatic meta tag generation
- Sitemap: Auto-generated sitemap.xml
- Robots.txt: Search engine instructions
- Schema markup: Structured data for search engines
- Open Graph: Social media sharing optimization
Built-in performance features:
- Static Site Generation: Fast loading times
- Image Optimization: Lazy loading and optimization
- Code Splitting: Minimal JavaScript bundle
- Caching: Optimized cache headers
- CDN Ready: Optimized for CDN deployment
-
Create custom theme:
mkdir docs/.vitepress/theme touch docs/.vitepress/theme/index.ts
-
Extend default theme:
import DefaultTheme from 'vitepress/theme' export default { extends: DefaultTheme, // Custom theme configuration }
Create reusable Vue components:
<!-- docs/.vitepress/theme/components/CustomComponent.vue -->
<template>
<div class="custom-component">
<!-- Component content -->
</div>
</template>
<script setup>
// Component logic
</script>Add VitePress plugins in config.ts:
export default defineConfig({
// ... other config
markdown: {
config: (md) => {
// Add custom markdown-it plugins
md.use(customPlugin)
}
}
})Add Google Analytics to the site:
- Update config.ts:
export default defineConfig({ // ... other config head: [ ['script', { async: '', src: 'https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID' }], ['script', {}, ` window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'GA_MEASUREMENT_ID'); `] ] })
Enable Netlify Analytics in Netlify dashboard:
- Go to Site settings β Analytics
- Enable Netlify Analytics
- Add tracking script if needed
The documentation includes built-in local search:
- Automatic indexing: All pages are indexed
- Fast search: Client-side search
- No dependencies: No external services needed
Replace local search with Algolia:
-
Install Algolia search:
npm install docsearch-js
-
Configure in config.ts:
export default defineConfig({ theme: defaultTheme({ search: { provider: 'algolia', options: { appId: 'YOUR_APP_ID', apiKey: 'YOUR_SEARCH_API_KEY', indexName: 'YOUR_INDEX_NAME' } } }) })
-
Create language directories:
mkdir docs/guide/fr mkdir docs/guide/es
-
Add language configuration:
export default defineConfig({ locales: { root: { label: 'English', lang: 'en-US' }, fr: { label: 'FranΓ§ais', lang: 'fr-FR' } } })
Test the documentation locally:
# Start development server
npm run dev
# Build and test production build
npm run build
npm run previewCheck all internal links:
# Install link checker
npm install -g markdown-link-check
# Check all markdown files
find docs -name "*.md" -exec markdown-link-check {} \;Follow these guidelines for consistent documentation:
- Use clear headings: Proper H1, H2, H3 hierarchy
- Write descriptive titles: SEO-friendly and clear
- Add frontmatter: Include title, description, navigation
- Use code blocks: Proper syntax highlighting
- Add examples: Practical code examples
- Include images: High-quality screenshots and diagrams
# Use # for main title (H1)
## Use ## for sections (H2)
### Use ### for subsections (H3)
# Use code blocks with language specification
```javascript
const example = 'code';Use variableName for inline code
| Column 1 | Column 2 |
|---|---|
| Value 1 | Value 2 |
- First step
- Second step
- Third step
This is an important note
## π Troubleshooting
### Common Issues
#### Build Errors
**Error: Module not found**
```bash
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install
Error: Permission denied
# Fix permissions
chmod +x docs/.vitepress/distHot reload not working
# Restart development server
npm run devStyles not loading
# Clear VitePress cache
rm -rf docs/.vitepress/cache- Check VitePress documentation: https://vitepress.dev
- Review configuration files: Check for syntax errors
- Test with minimal config: Start with basic configuration
- Check Node.js version: Ensure compatibility
Monitor site performance:
- Google PageSpeed Insights: https://pagespeed.web.dev
- Lighthouse: Built-in Chrome DevTools
- Web Vitals Extension: Chrome extension for monitoring
- Optimize images: Use WebP format, proper sizing
- Minimize CSS: Remove unused styles
- Lazy load content: Load content as needed
- Use CDN: Deploy to CDN for global performance
Keep dependencies updated:
# Check for updates
npm outdated
# Update dependencies
npm update
# Update VitePress
npm install vitepress@latestRegular maintenance tasks:
- Review documentation: Update outdated information
- Check links: Fix broken internal and external links
- Update examples: Ensure code examples work
- Optimize images: Compress and optimize images
- Documentation: Review existing documentation
- Community: Join VitePress community
- Issues: Report bugs on GitHub
- Discussions: Start a discussion for questions
Contribute to the documentation:
- Fork repository: Create your own copy
- Create branch: Work on your changes
- Submit PR: Propose your changes
- Review process: Wait for review and merge
Happy documenting! π
For more information about Yatra, visit wpyatra.com.