Set up Hugo with GitHub pages

This post briefly describes how to host Hugo blog on GitHub pages.

What is Hugo?

Hugo is a fast & modern static website engine. Hugo will break the barrier of setting up a web server to create a simple blog.

What is GitHub pages?

GitHub pages are static set of pages hosted on GitHub.

Setting up repositories

Create 2 GitHub repository to set up blog in GitHub pages.

  1. <blog-name>-hugo : For Hugo project
  2. <github username> : For hosting the blog

Clone the repo to your local machine using below command git clone<username>/<blog-name>-hugo.git

then setup <github username> as submodule git submodule add<username>/<username> Whatever the thing goes here can be accessed through http://<github username>

Install Hugo

Mac OS X: brew install hugo

Linux & Windows : Download binary file and install. Hugo includes all dependencies.

Create blog with Hugo

Lets create a new site for your blog

hugo new site <site name>
cd <site name>

After creating the new site, you need to edit config.toml configuration file according to your need. My configuration file looks like this.

baseurl = ""
languageCode = "en-us"
title = ""
theme = "hyde"
copyright = "Rajesh Hegde"
publishdir = ""

	name = "Rajesh Hegde"

	blog = "/:year/:month/:filename/"
	code = "/:filename/"

	tag = "tags"
	series = "series"
	series-desc = "series-desc"

	description = "extravaganza of Rajesh Hegde"
	twitter = ""
	github = ""
	disqus = ""

In the above configuration, change publishdir to <github username> Generated HTML will go here. And change the baseurl to your site name(http://<github username>

Create first page

hugo new will create a page in content/ directory

Run site locally

hugo server will host your blog on http://localhost:1313. Content of will be available at http://localhost:1313/about.

Deploy site

Let us generate the site using hugo which will generate all HTMLs in <github username> directory. This directory need to be pushed to github to be able to access on http://<github username> Since <github username> is a submodule, while pushing any changes to blog use this command git push --recurse-submodules=on-demand.

Now your site is available at http://<github username> Kudos…