Skip to content

Docsify

Setting up a Docsify site with Netlify provides an extremely fast and simple way to publish documentation. Docsify generates your documentation on the fly from Markdown files, requiring almost no static build step, which simplifies deployment significantly.

Here is a detailed, step-by-step guide for installation, customization, and continuous deployment.


1. Local Docsify Setup and Project Initialization

Docsify is a Node.js-based tool. You'll need Node.js and npm (or yarn/pnpm).

1.1. Install Prerequisites and Docsify CLI

  1. Install Node.js (LTS version recommended).
  2. Install the Docsify CLI globally:
    npm install -g docsify-cli
    # OR: yarn global add docsify-cli
    

1.2. Create a New Docsify Site

Use the Docsify CLI to quickly initialize a basic project.

  1. Initialize the project:
    docsify init ./my-docsify-site
    
  2. Navigate into the new directory:
    cd my-docsify-site
    
    This command creates the core files: index.html (the main entry point), README.md (the homepage content), and .nojekyll (prevents GitHub Pages processing).

1.3. Local Test

Run the development server to verify the default site.

docsify serve

Your site will be running at http://localhost:3000/. Press Ctrl+C to stop the server.


2. Custom Layouts, Partials, and Static Assets

Docsify's structure is minimal. Customization is handled primarily within the index.html file (the main layout) and through Markdown includes (Partials).

2.1. Project File/Folder Structure Tree

Your project structure, after customization, will look like this:

my-docsify-site/
├── docs/                    # (Optional) Subdirectory for Markdown content
├── .nojekyll                # Stops GitHub from building it as a Jekyll site
├── images/                  # Static assets (images, logos)
│   └── logo.png
├── index.html               # The main entry point (Layout/HTML shell)
├── README.md                # The site homepage content
├── _coverpage.md            # Content for the optional cover page
├── _sidebar.md              # Navigation partial (menu structure)
└── custom/                  # Custom CSS/JS assets
    ├── custom.css           # Custom styles
    └── custom.js            # Custom scripts/plugins

2.2. Customize the Main Layout (index.html)

The index.html file acts as the primary layout. It controls the site metadata, theme, and script injections.

  1. Open index.html and locate the script block defining the global configuration object (window.$docsify).

  2. Add Configuration: Ensure your configuration is set up correctly for the navigation, themes, and custom assets.

    <script>
      window.$docsify = {
        name: 'My Docsify Project',
        repo: 'https://github.com/user/repo', // Optional, for GitHub link
        loadSidebar: true, // Load _sidebar.md
        // ... other configurations
      }
    </script>
    

2.3. Create Partials (_sidebar.md)

The primary partial in Docsify is the navigation menu, controlled by _sidebar.md.

  1. Create the sidebar file:
    touch _sidebar.md
    
  2. Define the Navigation Structure: (Uses standard Markdown linking)
    • File: _sidebar.md
      * [Home](/)
      * [Getting Started](/getting-started)
      * [API Reference](/api-reference)
      

2.4. Manage Static Assets (Custom CSS/JS)

Custom assets need to be linked directly in index.html.

  1. Create the Custom Assets directory:

    mkdir custom
    
  2. Add Custom CSS:

    • File: custom/custom.css
    • Add some basic styling:
    :root {
      --theme-color: #3f51b5; /* Example: changing the primary color */
    }
    .markdown-section h1 {
      border-bottom: 2px solid var(--theme-color);
      padding-bottom: 5px;
    }
    
  3. Link the Custom CSS in index.html: Add a <link> tag within the <head> section of index.html.

    <link rel="stylesheet" href="/custom/custom.css"> 
    

2.5. Final Local Check

Run the server again:

docsify serve

Verify that the custom layout (if any), the sidebar, and the custom CSS are loading correctly.


3. GitHub Setup

3.1. Verify .gitignore

Docsify doesn't generate a standard build folder, so the .gitignore can be minimal, ensuring only node modules are excluded.

touch .gitignore
echo "/node_modules/" >> .gitignore

3.2. Commit and Push to GitHub

  1. Initialize Git:
    git init
    
  2. Add all files and commit:
    git add .
    git commit -m "Initial Docsify setup with custom styles and sidebar"
    
  3. Create a new repository on GitHub (e.g., named my-docsify-netlify).
  4. Link your local repo and push: (Replace placeholders)
    git remote add origin https://github.com/<your_username>/<repo_name>.git
    git branch -M main
    git push -u origin main
    

4. Netlify Setup for Continuous Deployment

Because Docsify only uses static files and no complex build process, Netlify deployment is extremely simple.

4.1. Sign Up and Import Project

  1. Go to the Netlify website and log in.
  2. In the Netlify dashboard, click "Add new site" then "Import an existing project".
  3. Select "GitHub" and choose your repository (my-docsify-netlify).

4.2. Configure Build Settings (Minimal)

Since Docsify does not require a build step, the settings are minimal. We are only telling Netlify which folder contains the files to publish.

Setting Value Note
Branch to deploy main The branch Netlify monitors.
Build command (Leave Blank) No command needed since Docsify runs entirely on the client-side.
Publish directory . (the project root) The root directory contains index.html, README.md, and all assets.

4.3. Deploy the Site

Click the "Deploy site" button. Netlify will:

  1. Fetch your GitHub code.
  2. Skip the build command.
  3. Publish the contents of the root directory (.).

Your Docsify site will be live on a temporary Netlify URL.


5. Ongoing Workflow

The Continuous Deployment (CD) pipeline is now established:

  1. Make changes locally (update content in Markdown files, edit the sidebar, or tweak index.html).
  2. Commit your changes:
    git commit -am "Updated documentation content and added a section to the sidebar."
    
  3. Push to GitHub:
    git push origin main
    
  4. Netlify automatically detects the push and instantly deploys the new static files.