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
- Install Node.js (LTS version recommended).
- Install the Docsify CLI globally:
1.2. Create a New Docsify Site
Use the Docsify CLI to quickly initialize a basic project.
- Initialize the project:
- Navigate into the new directory:
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.
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.
-
Open
index.html
and locate the script block defining the global configuration object (window.$docsify
). -
Add Configuration: Ensure your configuration is set up correctly for the navigation, themes, and custom assets.
2.3. Create Partials (_sidebar.md
)
The primary partial in Docsify is the navigation menu, controlled by _sidebar.md
.
- Create the sidebar file:
- Define the Navigation Structure: (Uses standard Markdown linking)
- File:
_sidebar.md
- File:
2.4. Manage Static Assets (Custom CSS/JS)
Custom assets need to be linked directly in index.html
.
-
Create the Custom Assets directory:
-
Add Custom CSS:
- File:
custom/custom.css
- Add some basic styling:
- File:
-
Link the Custom CSS in
index.html
: Add a<link>
tag within the<head>
section ofindex.html
.
2.5. Final Local Check
Run the server again:
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.
3.2. Commit and Push to GitHub
- Initialize Git:
- Add all files and commit:
- Create a new repository on GitHub (e.g., named
my-docsify-netlify
). - Link your local repo and push: (Replace placeholders)
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
- Go to the Netlify website and log in.
- In the Netlify dashboard, click "Add new site" then "Import an existing project".
- 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:
- Fetch your GitHub code.
- Skip the build command.
- 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:
- Make changes locally (update content in Markdown files, edit the sidebar, or tweak
index.html
). - Commit your changes:
- Push to GitHub:
- Netlify automatically detects the push and instantly deploys the new static files.