Hugo, as a static website generator, has many features we want but lacks some functionalities. Fortunately, Hugo supports custom HTML and CSS, allowing us to add desired features to our website. The following guide explains how to add a custom partner/friend page in Hugo.
Adding Partner/Friend Cards
Using a card format instead of traditional hyperlinks to partner websites is both visually appealing and practical.The left image shows the hyperlink format, while the right image displays the card format.
Creating the friend.html File
In the website’s root directory, navigate to /layouts/shortcodes/ and create a new file named friend.html. Then, insert the following content:
In the website’s root directory, navigate to /assets/css/_partial/_single/ and create a new file named _friend.scss. Then, insert the following content:
Now, we can create a page specifically to store partner/friend cards. Of course, the following steps are not mandatory to follow exactly as I have; you can create your own style for the page.
Creating the Card Storage Page
In the website’s root directory, navigate to /content/ and create a /friend/ folder (subdirectory). Inside this folder, add the index.zh-tw.md and index.en.md markdown files for the webpages.
Note
If your website is single-language, you only need to add index.your-language-code.md. If your website supports multiple languages, add the corresponding index.your-language-code.md files for each language supported by your site.
Create the friend_page.html File
In the website’s root directory, navigate to /layouts/shortcodes/ and create a new file named friend_page.html. Then, insert the following content:
Hugo will automatically select the appropriate language and display the corresponding partner page from the /content/friend/ directory in the website’s root.
Conclusion
Actually, I am not very familiar with Hugo’s shortcode, but perhaps because I am experienced with other programming languages, I was able to solve the bugs I encountered during this implementation. Website beautification tests the hands-on ability of every website operator, and being able to create both beautiful and functional features really brings a sense of accomplishment.
Environment
Hugo 0.144.2
LoveIt theme (version from GitHub on February 21, 2025)
Some content of this article is reproduced, adapted, and forwarded with the permission of the original author, Stilig, as referenced in the source. The rest of the content is original.
The content of this article is partially reproduced, adapted, and forwarded with the permission of the original author, Stilig, as referenced in the source. Authorized images.