This guide will walk you through the process of installing a theme for your Hugo site. Whether you're new to Hugo themes or just looking for a reliable setup reference, this tutorial has you covered with simple steps and helpful insights.
Table of Contents
- Prerequisites
- Setting Up Your Hugo Project
- Installing the Theme
- Using an Alternative Project Directory
- How Themes Work in Hugo (Quick Overview)
- Updating the Theme
- Running Your Site Locally
- Conclusion
Prerequisites
You'll need Hugo and Git installed on your computer to get started.
After installation, confirm that both are working:
hugo version
git --version
Setting Up Your Hugo Project
If you don’t already have a Hugo project, let’s create one!
- Start a Hugo project in a directory called
app
:
hugo new site app
- Move into your new project:
cd app
Installing the Theme
You can add a Hugo theme in two main ways: using a Git submodule or downloading it manually.
Method 1: Git Submodule (Best for Easy Updates)
- Add the theme to your Hugo project:
git submodule add https://github.com/theme-author/theme-repo.git themes/theme-folder
- Open
config.toml
(orconfig.yaml
) and set your theme:
theme = "theme-folder"
Method 2: Manual Download
- Download the theme from its GitHub repository and unzip it.
- Place the unzipped folder into
app/themes/
, naming ittheme-folder
. - Update
config.toml
:
theme = "theme-folder"
Using an Alternative Project Directory
If your Hugo project is located in a different directory (e.g., ./app/hugo-site
), you’ll just need to adjust paths:
- Move to the project root:
cd ./app/hugo-site
Install the theme as described above in
./app/hugo-site/themes/theme-folder
.In
config.toml
, set the theme:
theme = "theme-folder"
- Run Hugo from this directory to view your site:
hugo server -D
How Themes Work in Hugo (Quick Overview)
Themes in Hugo bundle templates, layouts, and assets, giving your site a professional look with minimal setup. When Hugo builds your site, it merges the theme files with your content files to create the final website.
Updating the Theme
If you installed the theme as a Git submodule, updating is straightforward:
- Navigate to the theme folder:
cd app/themes/theme-folder
- Pull the latest updates:
git pull origin main
-
Return to your project directory:
cd ../..
Commit the update:
git add themes/theme-folder
git commit -m "Update theme to latest version"
For manual installs, just replace the old theme folder with a fresh download.
Running Your Site Locally
Once the theme is installed, run your site locally to preview it:
hugo server -D
Check out http://localhost:1313
in your browser to see the theme in action.
Conclusion
With these steps, you're set up to install any Hugo theme with ease! For more theme customization options and resources, explore the Hugo documentation.
Enjoy building your beautifully themed Hugo site!
Top comments (0)