Tutorials
Beginner Tutorials
1. Creating Your First Documentation Site
- Install Nextra:
npm install nextra nextra-theme-docs- Create your first page:
# Welcome to My Docs
This is my first documentation page!- Start the development server:
npm run dev2. Adding Navigation
- Create a
_meta.jsfile:
export default {
"index": "Introduction",
"getting-started": "Getting Started"
}- Add more pages to your navigation.
3. Customizing the Theme
- Create a
theme.config.jsxfile:
export default {
logo: <span>My Project</span>,
project: {
link: 'https://github.com/your-repo'
}
}- Customize the theme to match your brand.
Intermediate Tutorials
1. Adding Custom Components
- Create a components directory:
mkdir components- Create your first component:
// components/Button.jsx
export function Button({ children }) {
return <button className="custom-button">{children}</button>
}- Use the component in your MDX:
import { Button } from '../components/Button'
<Button>Click me!</Button>2. Implementing Search
- Enable search in your theme config:
export default {
search: {
component: null
}
}- Customize the search experience.
3. Adding Internationalization
- Create language directories:
mkdir pages/en pages/zh- Configure language support in
_meta.js.
Advanced Tutorials
1. Creating Custom Themes
- Create a theme directory:
mkdir theme- Implement your custom theme components.
2. Optimizing Performance
- Implement code splitting:
import dynamic from 'next/dynamic'
const DynamicComponent = dynamic(() => import('../components/Heavy'))- Optimize images and assets.
3. Deploying Your Site
- Build your site:
npm run build- Deploy to your preferred platform:
- Vercel
- Netlify
- GitHub Pages
- AWS Amplify