Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Hosting Technical Documentation Using Docsify on GitHub

Tech May 16 1

Environment Prerequisites

Before beginning, ensure that the node and npm environments are configured on your system. If these are not yet installed, follow the steps below:

  1. Visit the official website: https://nodejs.org/ and download the Long Term Support (LTS) version.
  2. Proceed with the installation wizard. The default settings usually configure the environment variables automatically.
  3. Once installation completes, open the command prompt to verify the version and environment paths. Note that initially, only the root directory may be added to the system PATH.
  4. Configure the npm prefix, cache directory, and registry mirror using the following commands:
npm config set prefix "C:\dev\environment\node_global"
npm config set cache "C:\dev\environment\node_cache"
npm config set registry=https://registry.npmmirror.com

Verify the configuration by running npm config list.

Additionally, add the global modules path to your system environment variables. Adjust the path below based on your actual installation directory:

C:\dev\environment\node_global\node_modules

If commands installed via npm are not recognized, ensure the global binary folder is also added to the Path variable:

C:\dev\environment\node_global

With these settings applied, the environment is ready for package installation.

Initializing Docsify

Visit the official documentation at https://docsify.js.org/ for reference. To begin, install the command-line interface globally:

npm install docsify-cli -g

Create a directory for your documentation project, for example, tech-wiki, and navigate into it via the terminal:

cd tech-wiki
docsify init ./source

This generates the necessary file structure. To preview the site locally, run the serve command:

docsify serve ./source

The site will be accessible at http://localhost:3000. Changes to markdown files are reflected automatically upon saving without requiring a server restart.

Customizing the Interface

The default appearance is minimal. To enhance the user experience, several configurations can be adjusted in the index.html file.

Cover Page

Enable the cover page by setting the corresponding property to true in the configuration script:

coverpage: true

Create a file named _coverpage.md in the source directory with the following content:

# System Architecture Guide

> Comprehensive technical reference and notes

[View on GitHub](https://github.com/username/repo)
[Get Started](#introduction)

Sidebar Navigation

Enable the sidebar loading feature:

loadSidebar: true

Create a file named _sidebar.md to define the navigation structure:

- Guides

  - [Installation](installation.md)
  - [Configuration](configuration.md)
  - [API Reference](api.md)

Complete Index Configuration

The main content area renders the README.md file. Below is a refined version of the index.html structure including essential plugins for search, code copying, and image zooming.


<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Tech Wiki Documentation</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
</head>
<body>
  <div id="app"></div>
  <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
  <script src="//unpkg.com/docsify-copy-code"></script>
  <script src="//unpkg.com/docsify/lib/plugins/zoom-image.min.js"></script>
  <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
  <script>
    window.$docsify = {
      name: 'Tech Wiki',
      repo: 'https://github.com/username/project-repo',
      maxLevel: 4,
      subMaxLevel: 2,
      homepage: 'README.md',
      coverpage: true,
      loadSidebar: true,
      auto2top: true,
      search: {
        maxAge: 86400000,
        paths: 'auto',
        placeholder: 'Type to search...',
        noData: 'No matches found',
        depth: 3
      }
    }
  </script>
</body>
</html>

Deploying to GitHub Pages

To host the documentation online, initialize a git repository within the project folder and link it to a remote repository:

git init
git remote add origin "https://github.com/username/your-repository.git"

Commit and push the files to the remote repository. Standard git workflows apply here; alternatively, you may clone an existing repository first and then initialize docsify within it.

Once pushed, navigate to the repository settings on GitHub. Locate the Pages section (formerly GitHub Pages). Select the source branch (e.g., master or main) and the folder directory (e.g., /docs or root). After saving, the site will be publihsed and accessible via the provided URL.

Note: Accessibility may vary depending on regional network configurations. If the site fails to load, check DNS settings or network connectivity.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.