Hugo

Hugo Setup and Deploy

Web

🚀 Hugo + GitHub Pages Setup (User Site) #

Minimal setup using hugo-book theme inside a Conda environment, with GitHub Pages deployment.


1. Create and Activate Conda Environment #

conda create -n hugo-env
conda activate hugo-env

2. Install Hugo & Create Hugo Site with hugo-book Theme #

# Install Hugo
sudo apt install hugo         # Or: brew install hugo

# Create Hugo site
hugo new site hugo-site
cd hugo-site

# Initialize git and add theme
git init
git submodule add https://github.com/alex-shpak/hugo-book themes/hugo-book

3. Configure config.toml #

baseURL = 'https://your-username.github.io/'
languageCode = 'en-us'
title = 'My Hugo Site'
theme = 'hugo-book'

[params]
  BookTheme = 'light'
  BookToC = true
  BookCollapseSection = true
  BookFlatSection = false

[[menu.sidebar]]
  name = "Knowledge Graph"
  url = "/kg/"
  weight = 1

4. Create Content and _index.md Files #

# Create directories and content
mkdir -p content/kg/topic1
touch content/_index.md
touch content/kg/_index.md
touch content/kg/topic1/_index.md
hugo new kg/topic1/intro.md

Directory Structure #

content/
├── _index.md
├── kg/
│   ├── _index.md
│   └── topic1/
│       ├── _index.md
│       └── intro.md

_index.md contents #

content/_index.md

...

Hugo Source Backup

Web

🔒 Hugo Source Backup #

This guide outlines how to back up your Hugo source files (excluding the public/ folder) to a private GitHub repository.


📁 Folder Structure #

Typical Hugo project structure:

hugo-site/
├── archetypes/
├── content/
├── layouts/
├── static/
├── themes/
├── config.toml
├── public/           # <- This is ignored for source backup
└── backup.sh         # Backup script

✅ 1. Create a Private GitHub Repo #

  • Go to https://github.com/new
  • Name it something like hugo-source
  • Set visibility to Private
  • Don’t initialize with README or license

✅ 2. Initialize Git in Your Hugo Site (if not already) #

git init
git remote add origin https://github.com/<your-username>/hugo-source.git
echo "public/" >> .gitignore

✅ 3. Create the Backup Script #

Create a file named backup.sh in the root of your Hugo project:

...