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.xml for 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

Image

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

CommandDescription
localGenerate sitemap from local Markdown files

Global Options

FlagDescription
-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-underscoreIgnore files and folders starting with _ or . when generating sitemap
-h, --helpDisplay help for commands
-V, --versionOutput 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

OptionTypeDefaultDescription
urlstringโ€”Required. Site URL or GitHub Pages URL
ownerstringโ€”GitHub owner/org (for repo mode)
repostringโ€”Repository name (for repo mode)
branchstringmainBranch containing your Docsify site
basestring.Base folder in repo or local filesystem
patstringโ€”GitHub PAT to increase rate limit
outputstring./public/sitemap.xmlOutput file path
ignore-dot-underscorebooleanfalseIgnore files and folders starting with _ or .

Contributing

  1. Fork the repository
  2. Create a branch: git checkout -b feature/your-feature
  3. Make your changes and test
  4. 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.