Setting Up GitHub Pages for Documentation
This guide will help you deploy your documentation to GitHub Pages automatically using GitHub Actions.
π Quick Setup (5 minutes)
Step 1: Enable GitHub Pages
-
Go to your repository on GitHub:
https://github.com/ahmad2point0/react-app-folder-structure - Navigate to Settings:
- Click the βSettingsβ tab in your repository
- Configure Pages:
- Scroll down to βPagesβ in the left sidebar
- Under βSourceβ, select βGitHub Actionsβ
- β This will use our automated workflow
Step 2: Commit and Push Your Changes
# Add all the new files
git add .
# Commit the changes
git commit -m "feat: add GitHub Pages documentation setup"
# Push to GitHub
git push origin main
Step 3: Watch the Magic Happen
- Go to the Actions tab in your GitHub repository
- Watch the workflow run - it takes about 2-3 minutes
-
Check the deployment - your site will be live at:
π https://ahmad2point0.github.io/folder-structures/
π§ What Happens Automatically
Our GitHub Actions workflow (.github/workflows/pages.yml) will:
- Trigger on every push to the
mainbranch - Install Ruby and Jekyll in the GitHub runner
- Install all gems from your
Gemfile - Build the documentation using Jekyll
- Deploy to GitHub Pages automatically
π Files Created for GitHub Pages
.github/
βββ workflows/
βββ pages.yml # GitHub Actions workflow
_config.yml # Jekyll configuration
index.md # Homepage
contributing.md # Contributor guide
react-native-expo.md # Template documentation
Gemfile # Ruby dependencies
π οΈ Configuration Details
GitHub Actions Workflow Features
- β Automatic deployment on push to main
- β Manual trigger option from Actions tab
- β Ruby 3.2 with automatic gem caching
- β Jekyll production build with proper baseurl
- β Secure deployment with proper permissions
Jekyll Configuration Highlights
# _config.yml key settings
title: React App Folder Structure Templates
baseurl: "/react-app-folder-structure"
url: "https://ahmad2point0.github.io"
theme: just-the-docs
π Verification Steps
After deployment, verify everything works:
- Visit your site: https://ahmad2point0.github.io/folder-structures/
- Test navigation: Click through different pages
- Test search: Use the search functionality
- Check mobile: View on mobile devices
- Verify links: Make sure all internal links work
π Troubleshooting
Common Issues:
1. Workflow fails to build:
- Check the Actions tab for error details
- Most common: Gemfile issues or Jekyll configuration errors
2. Site loads but styling is broken:
- Check the
baseurlin_config.yml - Make sure it matches your repository name
3. Links donβt work:
- Use relative links for internal pages
- Example:
[Contributing](contributing.html) - For markdown files, use
.htmlextension in links
4. Images donβt load:
- Place images in
assets/images/ - Use relative paths:

Debug Commands (Local Testing):
# Test the exact build process GitHub uses
JEKYLL_ENV=production bundle exec jekyll build --baseurl "/react-app-folder-structure"
# Serve with the same baseurl
bundle exec jekyll serve --baseurl "/react-app-folder-structure"
π Workflow Triggers
The documentation will automatically rebuild when you:
- β Push to main branch - Automatic deployment
- β Manual trigger - From GitHub Actions tab
- β Pull request merge - When PRs are merged to main
π Monitoring
Check Deployment Status:
- Actions Tab: See build and deployment progress
- Environments: View deployment history and URLs
- Pages Settings: Monitor overall Pages configuration
Performance:
- Build time: ~2-3 minutes for full deployment
- Cache: Ruby gems are cached for faster subsequent builds
- CDN: GitHub Pages uses a global CDN for fast loading
π― Custom Domain (Optional)
To use a custom domain like docs.yoursite.com:
- Add CNAME file:
echo "docs.yoursite.com" > CNAME git add CNAME && git commit -m "add custom domain" - Configure DNS:
- Add CNAME record pointing to
ahmad2point0.github.io
- Add CNAME record pointing to
- Update _config.yml:
url: "https://docs.yoursite.com" baseurl: ""
π Next Steps
After your documentation is live:
- Share the link with contributors
- Add the URL to your repository description
- Include it in your main project README
- Set up branch protection to require PR reviews
π Maintenance
Your documentation will stay automatically updated as you:
- Add new framework templates
- Update existing documentation
- Accept contributor pull requests
The GitHub Actions workflow handles everything automatically! π
π Your documentation will be live at: https://ahmad2point0.github.io/folder-structures/