Introduction
As promised, I have prepared a tutorial on creating a static site using Hugo and deploying it on GitHub Pages. I will update this post with every change I make to my own site and add any new features I use.
Difference Between Static and Dynamic Sites
The first thing we need to discuss is whether you need a static site or a dynamic site. A static site is a collection of html, css, or JavaScript files that are displayed to the user exactly as they were coded. Any changes are only shown to the user by modifying the site’s code. In contrast, a dynamic site displays content interactively to the user without needing to edit the code, and its content can be changed dynamically. Now, let’s compare these two types of sites.
Static sites are very fast and require minimal cost for development and setup. However, their content is fixed, they have very limited features, and managing the site becomes very difficult as it grows.
Dynamic sites have dynamic content. They can interact with users, content management is very easy, and they have advanced features. However, they are slower, more complex to develop, and require significantly higher costs for setup and maintenance.
Which One Should I Choose
If you are a blogger, need a small personal site, or want to create a small educational site, it is better to use a static site. However, if you are planning a large project, a commercial venture, or something like an online store, you should definitely opt for a dynamic site.
Setting Up a Static Site with Hugo and GitHub Pages
Introduction
Hugo is a fast and modern framework for building static sites, written in Go. GitHub Pages is a free hosting service for static sites. Combining these two provides an ideal solution for creating blogs, documentation, or personal websites.
Advantages
- High Speed: Static Hugo sites load very quickly.
- Security: Without a database or backend code, vulnerabilities are reduced.
- Free: GitHub Pages provides hosting services for free.
- Easy Management: With Git, you can have a complete history of changes.
- Diverse Themes: Hundreds of free themes are available for Hugo.
Prerequisites
- Install
Git(Download) - A
GitHubaccount (Sign up) - Install
Hugo(Installation Guide)
Setup Steps
1. Install Hugo
To install Hugo, go to this address and install it according to your operating system.
I use Arch Linux, so I’ll install it with pacman:
| |
2. Create a New Hugo Project
Now open the terminal and navigate to the directory where you want your site to be created, then run:
| |
That’s it. You now have a static site.
3. Add a Theme
Go to the Hugo Themes site and choose a theme for your site. Make sure to select a multilingual theme. I chose the stack theme.
To install stack, the best way is to use the ready-made template they’ve provided. Go to this address and click on Use this template.

Now select Create new repository.
In the window that opens, in the Repository name field, choose the name for the new repository, which is your site. The name format should be like this:
| |
where username is your GitHub username.
Now click create repository. That’s it, and your site with the stack theme is set up on GitHub. There’s just one more step: go to the settings of the created repository and select Pages. Now change the Build branch from master to gh-pages.

Okay, our work here is done, and we don’t need to do anything else here.
4. Clone the Site Locally
Congratulations! You’ve done well so far. Let’s create a clone of our site on our local system.
Open the terminal and enter this command:
| |
Replace username with your own username. For example, if you want to clone my site:
| |
Now go to the site folder:
| |
And run Hugo:
| |
The output will give you a link where you can see the local output of your site:
| |
For me, it’s: http://localhost:1313/
5. First Site Post
Let’s create a new page. To do this, enter this command:
| |
A new markdown file will be created for you in the content folder.
Tip: Use an editor like vscode for writing markdown files.
Copy this text into the file:
| |
Hugo reads the top part of the file and decides what to do with it. For example, when the file was created, what the page title is, or what tags should be introduced for this page.
The last line is what you will see in your first post. Close the file and run Hugo again.
| |
6. Configure the config.toml File
The configuration file is usually located at the root of the project, but sometimes you can also find it in the config or config/_default folder.
You can see a simple example of the config:
| |
My config looks like this:
| |
All my site’s config is created in separate files:
| |
Tip: You can use only one file and copy all these settings into the config.toml file.
I use the languages.toml file for making the site bilingual:
| |
7. Upload Changes to GitHub
| |
Important Notes
Custom Domain
If you want to use a custom domain:
- Create a
CNAMEfile in thestaticfolder. - Enter your domain name in it.
- Configure your
DNSaccording to the GitHub Pages guide.
Search Engine Optimization
- Use SEO-Friendly themes.
- Configure meta tags correctly.
- Choose a readable URL structure.
Persian Language Support
- Set the
languageCodevalue tofa-irinconfig.toml. - Use themes with RTL support.
- Add appropriate Persian fonts.
Useful Resources
Conclusion
Using Hugo and GitHub Pages, you can set up a professional static site in the shortest time and at no cost. This method is ideal for bloggers, developers, and small businesses.