Docsify Sitemap Generator
May 29, 2025 ยท View on GitHub
Generate an SEO friendly sitemap.xml for your Docsify site in seconds.
This tool supports both local filesystem crawling and GitHub repository integration, giving you maximum flexibility.
Features
- Local & GitHub: Crawl Markdown files locally or fetch from a GitHub repo.
- Sitemap Standards: Generates a fully compliant
sitemap.xmlfor optimal search engine indexing. - Rate Limit Friendly: Support for GitHub Personal Access Tokens (PAT) to avoid API throttling.
- Customizable: Configure base directories, branches, output paths, and more.
- Flexible Workflows: Use via CLI or Web UI choose what fits your pipeline.
Live Demo
Try it now without installing: Docsify Sitemap Generator Web UI
Preview
Installation
Install as a development dependency:
npm install --save-dev docsify-sitemap
# or
yarn add --dev docsify-sitemap
Or globally:
npm install -g docsify-sitemap
# or
yarn global add docsify-sitemap
Quick Start
Run the CLI and follow prompts:
npx docsify-sitemap
Youโll be asked for your site URL, GitHub repo details (if applicable), and output location. A sitemap.xml file will be generated in your project.
CLI Usage
docsify-sitemap [command] [options]
Commands
| Command | Description |
|---|---|
local | Generate sitemap from local Markdown files |
Global Options
| Flag | Description |
|---|---|
-u, --url <url> | (required) Website URL (e.g. https://user.github.io/repo) |
-o, --owner <o> | GitHub owner or organization (required for repo mode) |
-r, --repo <r> | GitHub repository name (required for repo mode) |
-b, --base <dir> | Base directory within repo or local path (default: .) |
-B, --branch <b> | Git branch (default: main) |
-p, --pat <token> | GitHub Personal Access Token for private repos or higher rate limit |
-f, --output <f> | Output path and filename (default: ./public/sitemap.xml) |
-i, --ignore-dot-underscore | Ignore files and folders starting with _ or . when generating sitemap |
-h, --help | Display help for commands |
-V, --version | Output the current version |
Examples
Basic use
npx docsify-sitemap \
-u https://user.github.io/repo \
-o user \
-r repo \
-b docs \
-p YOUR_GH_PAT \
-f ./docs/sitemap.xml
-i
Automated GitHub Action
name: Generate Sitemap
on:
push:
paths:
- "**/*.md"
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Generate sitemap
run: npx docsify-sitemap local -u WEBSITE_URL
- name: Commit sitemap
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add .
git diff --cached --quiet || git commit -m 'chore: update sitemap.xml'
git push
๐ง API & Options Reference
| Option | Type | Default | Description |
|---|---|---|---|
url | string | โ | Required. Site URL or GitHub Pages URL |
owner | string | โ | GitHub owner/org (for repo mode) |
repo | string | โ | Repository name (for repo mode) |
branch | string | main | Branch containing your Docsify site |
base | string | . | Base folder in repo or local filesystem |
pat | string | โ | GitHub PAT to increase rate limit |
output | string | ./public/sitemap.xml | Output file path |
ignore-dot-underscore | boolean | false | Ignore files and folders starting with _ or . |
Contributing
- Fork the repository
- Create a branch:
git checkout -b feature/your-feature - Make your changes and test
- Submit a pull request
We welcome enhancements, bug fixes, and documentation improvements. Please follow existing code style and conventions.
License
This project is licensed under the MIT License.