Jae's Website
Random Beeps'n Boops

Logo

Improving my website with simple GoHugo tricks

- Published on 6th November, 2020 -

This article is older than a year and might be outdated!

As you may have seen, I started to really work on my website lately, I first switched to a homemade theme ([the article can be found here]({{< ref "/blog/2020/may2020-hugo-website.md" >}})) and then started to work on smaller tweaks of the theme while adding cool features such as Twitter's cards or integrating the OpenGraph protocol.

As you may know it, my website uses the GoHugo website generator (code under MIT license by the way) which is super easy to use and has a really good integration with Gitlab Pages.

Getting OpenGraph to work is one of the first really easy steps to have a nicer presence when your website is linked to another place. It basically shows as a little card with a bit of information such as the name of the website, the author, the description of the page and an image. Twitter's card are basically the same thing but for Twitter.

To add OpenGraph to your pages, just add this in the <head> of your template:

    {{ template "_internal/opengraph.html" . }}

The same goes on for Twitter's cards:

    {{ template "_internal/twitter_cards.html" . }}

At the end, the OpenGraph should produce an output like this:

{{< highlight html "linenos=table" >}}

{{< / highlight >}}

And the Twitter's cards:

{{< highlight html "linenos=table" >}}

{{< / highlight >}}

Some other improvements are regarding custom shortcodes, like the one I made for spoilers which shows like this:

Which generates this HTML output:

As you can see, this is actually really easy to improve small bits of your website if you really want to.

However, if you are not the maintainer of the theme you are currently using, open an issue telling the maintainer(s) those shortcodes actually exists or if you can, contribute!

However, more shortcodes are available on GoHugo's website including ones for Youtube, Instagram or Twitter.

Thatโ€™s all for today, I'll see you next time! If you like my content, don't forget to subscribe throught RSS!