Skip to content

Files

Latest commit

 

History

History
206 lines (166 loc) · 5.02 KB

github-page-static-site-tools.md

File metadata and controls

206 lines (166 loc) · 5.02 KB

Sure! Here’s a step-by-step guide on how to leverage GitHub Pages for each of the static site generators mentioned earlier: Jekyll, Hugo, MkDocs, Docusaurus, and VuePress.

1. Using Jekyll on GitHub Pages

Step 1: Install Jekyll

  • Install Jekyll and Bundler (if not already installed):
    gem install jekyll bundler

Step 2: Create a New Jekyll Site

  • Navigate to the directory where you want your site, then run:
    jekyll new your-site
    cd your-site

Step 3: Add Markdown Files

  • Place your markdown files in the _posts directory or any other directory as needed.

Step 4: Build and Serve Locally

  • To preview your site locally:
    bundle exec jekyll serve

Step 5: Create a GitHub Repository

  • Create a new repository on GitHub (e.g., yourusername.github.io for a personal site).

Step 6: Push to GitHub

  • Initialize a git repository, add your files, and push:
    git init
    git add .
    git commit -m "Initial commit"
    git remote add origin https://github.com/yourusername/yourusername.github.io.git
    git push -u origin main

Step 7: Enable GitHub Pages

  • Go to your repository settings, scroll down to the GitHub Pages section, and select the branch you want to use (usually main or gh-pages).

2. Using Hugo on GitHub Pages

Step 1: Install Hugo

  • Install Hugo using Homebrew (macOS) or Chocolatey (Windows):
    brew install hugo
    or
    choco install hugo

Step 2: Create a New Hugo Site

  • Create a new Hugo site:
    hugo new site your-site
    cd your-site

Step 3: Add Your Markdown Files

  • Move your markdown files into the content folder.

Step 4: Install a Theme

  • Add a theme (e.g., clone a theme into the themes directory) and update your config.toml:
    git submodule add https://github.com/themename/hugo-theme.git themes/hugo-theme
    Update config.toml:
    theme = "hugo-theme"

Step 5: Build the Site

  • Build and serve the site locally:
    hugo server

Step 6: Create a GitHub Repository

  • Create a new repository on GitHub.

Step 7: Push to GitHub

  • Push your files:
    git init
    git add .
    git commit -m "Initial commit"
    git remote add origin https://github.com/yourusername/yourusername.github.io.git
    git push -u origin main

Step 8: Enable GitHub Pages

  • As in Jekyll, go to the GitHub Pages section in your repository settings to enable it.

3. Using MkDocs on GitHub Pages

Step 1: Install MkDocs

  • Install MkDocs via pip:
    pip install mkdocs

Step 2: Create a New MkDocs Site

  • Create a new site:
    mkdocs new your-site
    cd your-site

Step 3: Add Markdown Files

  • Move your markdown files into the docs folder.

Step 4: Serve Locally

  • Preview your site:
    mkdocs serve

Step 5: Create a GitHub Repository

  • Create a new repository on GitHub.

Step 6: Deploy to GitHub Pages

  • Build the site and deploy:
    mkdocs gh-deploy

4. Using Docusaurus on GitHub Pages

Step 1: Install Docusaurus

  • Create a new Docusaurus site:
    npx create-docusaurus@latest your-site classic
    cd your-site

Step 2: Add Markdown Files

  • Add your markdown files to the docs folder.

Step 3: Serve Locally

  • Start the local development server:
    npm start

Step 4: Create a GitHub Repository

  • Create a new repository on GitHub.

Step 5: Build the Site

  • Build the site for deployment:
    npm run build

Step 6: Deploy to GitHub Pages

  • Deploy to GitHub Pages:
    GITHUB_TOKEN=your_github_token npm run deploy

5. Using VuePress on GitHub Pages

Step 1: Install VuePress

  • Create a new VuePress site:
    mkdir your-site
    cd your-site
    npm init -y
    npm install -D vuepress

Step 2: Add Markdown Files

  • Create a docs folder and place your markdown files there.

Step 3: Serve Locally

  • To run the development server:
    npx vuepress dev docs

Step 4: Create a GitHub Repository

  • Create a new repository on GitHub.

Step 5: Build the Site

  • Build the static files:
    npx vuepress build docs

Step 6: Deploy to GitHub Pages

  • Push the generated files (in docs/.vuepress/dist) to the gh-pages branch:
    git init
    git add docs/.vuepress/dist
    git commit -m "Deploy VuePress"
    git remote add origin https://github.com/yourusername/yourusername.github.io.git
    git push -u origin gh-pages

Final Steps for All Generators:

  1. After pushing your files, visit https://yourusername.github.io in your browser to see your live site.
  2. For any future updates, simply commit and push your changes to the corresponding branch.

If you have any specific questions about a particular step or need further clarification on any part, feel free to ask!