This guide explains how to build and test the FastMarkDocs documentation locally using Jekyll before pushing changes to GitHub.
# First time setup
./build-docs.sh setup
# Build and serve locally
./build-docs.sh serve# First time setup
make docs-setup
# Build and serve locally
make docs-serve# First time setup
.\build-docs.ps1 setup
# Build and serve locally
.\build-docs.ps1 serve-
Ruby (version 2.7 or higher)
- macOS:
brew install ruby - Ubuntu/Debian:
sudo apt-get install ruby-full - Windows: Download from RubyInstaller
- macOS:
-
Bundler (Ruby gem manager)
- Automatically installed by the build scripts
- Manual install:
gem install bundler
Check that you have the required tools:
ruby --version # Should be 2.7+
bundle --version # Should be 2.0+The main build script for Unix-like systems (macOS, Linux):
./build-docs.sh [COMMAND]Available Commands:
setup- Install dependencies and setup environmentbuild- Build the documentation onlyserve- Build and serve documentation locally (default)validate- Validate the built documentationclean- Clean build artifactshelp- Show help message
Environment Variables:
DOCS_PORT- Port for local server (default: 4000)DOCS_HOST- Host for local server (default: 127.0.0.1)
Examples:
# First time setup
./build-docs.sh setup
# Build and serve on default port (4000)
./build-docs.sh serve
# Serve on custom port
DOCS_PORT=3000 ./build-docs.sh serve
# Build only (no server)
./build-docs.sh build
# Clean build artifacts
./build-docs.sh cleanThe build script for Windows systems:
.\build-docs.ps1 [COMMAND] [-Port PORT] [-Host HOST]Examples:
# First time setup
.\build-docs.ps1 setup
# Build and serve on default port
.\build-docs.ps1 serve
# Serve on custom port
.\build-docs.ps1 serve -Port 3000
# Build only
.\build-docs.ps1 buildConvenient Make targets for common tasks:
# Show available commands
make docs-help
# Setup environment
make docs-setup
# Build and serve
make docs-serve
# Serve on custom port
make docs-serve DOCS_PORT=3000
# Clean build
make docs-clean
# Full rebuild
make docs-rebuild
# Production build
make docs-production
# Show statistics
make docs-statsIf you prefer to run Jekyll commands directly:
cd docs
bundle installcd docs
bundle exec jekyll buildcd docs
bundle exec jekyll serve --livereload --incrementalcd docs
JEKYLL_ENV=production bundle exec jekyll buildfastapi-markdown-docs/
├── docs/ # Documentation source
│ ├── _config.yml # Jekyll configuration
│ ├── Gemfile # Ruby dependencies
│ ├── index.md # Homepage
│ ├── getting-started.md # Getting started guide
│ ├── user-guide.md # User guide
│ ├── api-reference.md # API reference
│ ├── examples.md # Examples
│ ├── advanced.md # Advanced guide
│ └── _site/ # Generated site (after build)
├── build-docs.sh # Build script (Unix)
├── build-docs.ps1 # Build script (Windows)
└── Makefile.docs # Make targets
# Clone the repository
git clone https://github.com/danvatca/fastmarkdocs.git
cd fastmarkdocs
# Setup documentation environment
./build-docs.sh setupEdit the markdown files in the docs/ directory:
docs/user-guide.md- User guidedocs/api-reference.md- API referencedocs/examples.md- Examplesdocs/advanced.md- Advanced topics
# Start local server with live reload
./build-docs.sh serveVisit http://localhost:4000 to see your changes. The server will automatically reload when you save files.
# Validate the build
./build-docs.sh validate
# Or check with Make
make docs-lint# Test production build
make docs-productiongit add docs/
git commit -m "Update documentation"
git push origin mainProblem: Jekyll requires Ruby 2.7+
Solution:
# Check Ruby version
ruby --version
# Update Ruby (macOS with Homebrew)
brew upgrade ruby
# Update Ruby (Ubuntu)
sudo apt-get update && sudo apt-get upgrade ruby-fullProblem: Gem installation fails
Solution:
# Clear gem cache
gem cleanup
# Update bundler
gem update bundler
# Reinstall dependencies
cd docs
rm Gemfile.lock
bundle installProblem: Port 4000 is already in use
Solution:
# Use a different port
DOCS_PORT=3000 ./build-docs.sh serve
# Or with Make
make docs-serve DOCS_PORT=3000
# Or with PowerShell
.\build-docs.ps1 serve -Port 3000Problem: Permission denied when installing gems
Solution:
# Use user-local gem installation
bundle config set --local path 'vendor/bundle'
bundle installProblem: Jekyll build fails with errors
Solution:
# Check for syntax errors
make docs-lint
# Clean and rebuild
./build-docs.sh clean
./build-docs.sh build
# Check Jekyll doctor
cd docs
bundle exec jekyll doctor- Check Jekyll logs: Look for error messages in the build output
- Validate markdown: Ensure your markdown syntax is correct
- Check file paths: Verify all links and image paths are correct
- Test incrementally: Build after small changes to isolate issues
The documentation is automatically deployed to GitHub Pages when changes are pushed to the main branch.
The site is configured to deploy from the docs/ directory on the main branch:
- Repository Settings → Pages
- Source: Deploy from a branch
- Branch:
main - Folder:
/docs
To use a custom domain:
- Add a
CNAMEfile to thedocs/directory - Update the
urlandbaseurlindocs/_config.yml - Configure DNS settings with your domain provider
- Use incremental builds:
--incrementalflag (enabled by default in scripts) - Enable caching: Jekyll automatically caches builds
- Limit file watching: Use specific file patterns if needed
- Use live reload:
--livereloadflag (enabled by default) - Serve on local network: Use
--host 0.0.0.0to access from other devices - Custom port: Use different port if 4000 is busy
Edit docs/_config.yml to customize:
# Site settings
title: Your Site Title
description: Your site description
url: "https://yourusername.github.io"
baseurl: "/your-repo-name"
# Build settings
markdown: kramdown
highlighter: rouge
theme: minima
# Plugins
plugins:
- jekyll-feed
- jekyll-sitemap
- jekyll-seo-tagTo use a different theme:
-
Update
docs/Gemfile:gem "your-theme-name"
-
Update
docs/_config.yml:theme: your-theme-name
-
Run setup again:
./build-docs.sh setup
Add plugins to docs/Gemfile:
group :jekyll_plugins do
gem "jekyll-feed"
gem "jekyll-sitemap"
gem "jekyll-seo-tag"
gem "your-custom-plugin"
endThe repository includes a GitHub Actions workflow that automatically builds and deploys the documentation. See .github/workflows/ for configuration.
Test the build process locally before pushing:
# Run full build and validation
./build-docs.sh build
./build-docs.sh validate
# Test production build
make docs-production
# Check for issues
make docs-lintThis build system ensures that your documentation changes are properly tested locally before being deployed to GitHub Pages, maintaining high quality and preventing broken deployments.