DEV Community

Cover image for How to create Blog and Portfolio with Hugo : From A-to-Z
Pritesh Usadadiya
Pritesh Usadadiya

Posted on

How to create Blog and Portfolio with Hugo : From A-to-Z

It has been long time since i wanted to start a blog and host it with my own Custom domain.Truth to be told , I am a lazy blogger - I only write occasionally.

Originally I wanted to setup my blog on Wordpress but configuring and hosting a blog on VPS server (no mater how cheap) , requires regular maintenance on monthly basis.

Add that with Keeping server up-to-date to avoid any risks, backups etc... just seems extra work that i really don't want to do.

Other option was host a blog on Blogger and redirect to custom domain. which again didn't seem right because external dependency on Google.(They can remove your blog without any warning if they feel like it. Doesn't matter if they actually do or don't, but they can)

Now being from Technical background and my curiosity to learn , I turned to Static site generators. I have heard some great thing about Hugo so thought why not give it a try.

Hogo is a great choice as it has Github pages support and i can host entire thing for free with Github.

Setting up Hugo server locally.

Installing Hugo

There is entire section dedicated to installation for different environment detailed instructions .

Selecting Theme

after browsing some themes (and there are too many themes) i decided to go with silhouette-hugo.

Creating a new project template and forking a theme.

hugo new site <SITENAME>
cd <SITENAME>/themes
git clone
Enter fullscreen mode Exit fullscreen mode

Adding the theme to project's config file.

echo 'theme = "silhouette-hugo"' >> config.toml
Enter fullscreen mode Exit fullscreen mode

Starting the Hugo server locally

Hugo server
Enter fullscreen mode Exit fullscreen mode

Once the Hugo is started ,site can be previewed on http://localhost:1313

Changing the site data

Go to config.toml file of your project's main directory and from there you can change your sites configuration data like baseurl , title of site , social links etc...

Using some CSS to slightly change look and feel of theme.

Navigate to /themes/silhouette-hugo/assets/css

Here resides the styles.css file. you can change the style of the theme by editing this file.

From this


To this


I made a stupid mistake by editing the original theme and adding my own css with this.

Learn from my mistake and make a note of this , never ever ever edit the original files when you are using third part library/theme. Instead create your own new file and reference it.

[ One of the thing i love most about hugo is the instant changes in html page without any refresh. You could see the data changes in website as soon as you change/add css property.]

As Sites created with HUGO will be static site and Github provides a free hosting for static website, we are going to use Github Pages.

Create a Github Repository and Clone it on your Local Machine

First thing we need to do is to Create 2 Project repositories on GitHub. Name your first repository with exact name as your website directory YourProjectNanme (Project that you created in your local machine) and for the second one,name it as <YourUserName> This repository will contain static content created with Hugo.

Now, pull those repos to your local machine

cd <YourProjectNanme>
git clone
git clone
Enter fullscreen mode Exit fullscreen mode

Initialize your <YourProjectNanme> folder with below Command

git init
Enter fullscreen mode Exit fullscreen mode

And repo remotely with remote and add

git remote add origin
git pull origin master
Enter fullscreen mode Exit fullscreen mode

Edit Config File

Before we commit our changes we need to edit config.toml (Located in Root Directory of your Project 'YourProjectName') and change Base URL.

baseurl = "" // Change YourUserName with your GIthub Username 
--- OR ---
baseurl = "" // Custom Domain Name 
Enter fullscreen mode Exit fullscreen mode

Generate static content

Now lets generate static content with Hugo

hugo -d ../
Enter fullscreen mode Exit fullscreen mode

And now Push our Hugo Code to github repository

cd YourProjectName
git add .
git commit -m "your message"
git push origin master
Enter fullscreen mode Exit fullscreen mode

And Push Static content to github

git add .
git commit -m "your message"
git push origin master
Enter fullscreen mode Exit fullscreen mode

Configuring Custom Domain

In order to use custom domain with our gitthub pages, we will have to configure A records for our domain (you can do this wil help of DNS Provider)

Add below IP address as a A records on your domain.
Enter fullscreen mode Exit fullscreen mode

There are two way to add custom domain to our project.

  1. Create a CNAME file in our root directory of the project
  2. Use Settings option from github project repo and add a custom domain.
We are going with option 2

Open your github project repo and navigate to settings page.Scroll down untill you see GitHub Pages section and there will be a option to add custom domain there.

Add your custom domain and click on save button.There is a also another check box Enforce HTTPS. check it (It will provide a layer of encryption and your site will be viewed over HTTPS).

If you are using a www sub-domain, there are chances that you might not be able to check the Enforce HTTPS check-box.
I was also receiving a Privacy error with custom domain and i solved it by changing a DNS record.

I had added the CNAME record (you can add this using DNS Provider)

Enter fullscreen mode Exit fullscreen mode

Problem with above is that I was redirecting my www sub-domain to my apex(main) domain.

I Solved this issue by changing my CNAME record to

www CNAME // add your url here
Enter fullscreen mode Exit fullscreen mode

It takes around 48 hours for Github to generate HTTPS certificate on custom domain so, you might want to wait for it.

The End

A Note:

I am documenting this entire process just in case i might need it in future. Maybe this can be useful to you too.

Happy Coding.

Originally published on my own blog.

Creating a blog with Hugo static site Generator

Hosting Hugo site on Github Pages with Custom Domain

Top comments (3)

leekeith profile image
Keith Lee

Loved this post. I'm not a web dev, but I've been looking for a tool and a method to help me get my own page up. This may be it!

priteshusadadiya profile image
Pritesh Usadadiya

glad you liked it Keith. Do reach me out, if you need any help with setup.

gnharishkumar13 profile image

Hey, how do we enable newsletter/subscribe and comments(other than disqus). Thanks