Modify the font of the navigation bar in Hugo

The cover image is a comparison between the before and after modifications.
Introduction
When building a website, you may notice that the default font is not very appealing. This article will use Hugo as the static site generator and introduce how to change the navigation bar font to your preferred one.
Finding a Font
There are many websites offering fonts online. In this guide, we will use Google fonts to embed fonts into the website
Selecting a Font
First, visit Google fonts and choose a font you like. For example, I selected LXGW WenKai TC. Follow step one in the image below and click the Get font button.
Obtaining the Embed Code
In step two, click the <> Get embed code button.
Next, follow the instructions provided by Google fonts to embed the code into your website.
In step three, switch to the @import option.

Remember the code from steps four and five, as we will use it later.
Embedding the Font
Adjusting the Configuration
Next, locate the hugo.toml or config.toml file in the website root directory and find [params]. Add the following information.
| |
[params] parameter may vary depending on the Hugo theme and version. Please adjust accordingly.Adding the custom.css File
Navigate to the /assets/css/ directory in the website root and create a custom.css file. Then, add the code from steps four and five in #Obtaining the Embed Code.
| |
customCSS = "/css/custom.css" in hugo.toml or config.toml to any term of your choice. However, ensure that the term is consistent in both the configuration file and the filename in /assets/css/.At this point, the font has been successfully embedded into the website.
Changing the Navigation Bar Font
Viewing the Page Source Code
Here, we use Google Chrome to demonstrate how to extract the page source code. Use the appropriate method for your browser.
On any page of the website, right-click to open the menu and select View Page Source.
Find the text matching the navigation bar text and note the value of the class attribute before it. In the example below, the class attribute for the navigation bar text is menu-item.
Ctrl + F usually opens the page search.Modifying the custom.css File
Return to the /assets/css/custom.css file and add the following code to force the navigation bar font change.
| |
Remember to replace menu-item and "LXGW WenKai TC" with your class attribute value and font choice. Note that menu-item is preceded by a period (.), which should not be omitted.
The complete code will look like this.
| |
Modifying the link.html File
Finally, navigate to the /layouts/partials/head/ directory in the website root, locate the link.html file, and add the following code at the end to complete the font change for the navigation bar.
| |
custom match the filename set in #Adjusting the Configuration.Conclusion
Modifying a website’s font may seem like a small change, but it can significantly enhance the site’s visual appeal, making the overall design better suited to personal style and branding. By selecting the right font, a website can become more attractive and improve the user browsing experience. Additionally, we can assign specific fonts to different elements, adding more depth to the site’s design. Hopefully, this guide will help you successfully change the font of your website’s navigation bar and create a webpage that reflects your unique style!
Environment
- Hugo 0.144.2
- LoveIt theme (version from GitHub on February 21, 2025)
References
- Google. (n.d.). Google fonts. Google. Retrieved March 4, 2025, from https://fonts.google.com/

![[Test] Website Network Connection Speed Test](https://josh-test-lab.github.io/posts/Website%20Network%20Connection%20Speed%20Test/cover%20image.webp)
![[Thoughts] 2024 Joint Conference of University Administrators for Teacher Education](https://raw.githubusercontent.com/Josh-test-lab/website-assets-repository/refs/heads/main/posts/2024%20Joint%20Conference%20of%20University%20Administrators%20for%20Teacher%20Education/cover%20image.webp)


