Introduction

Being the owner of this blog, I often find joy in revisiting past endeavors that may no longer be part of my daily work. From fine-tuning website performance to delving into the intricacies of SEO, I relish the opportunity to explore various aspects of digital craftsmanship.

One aspect that particularly piques my interest is finding creative ways to monetize my blog without resorting to intrusive advertisements. As a steadfast supporter of Open Source principles, I value the ability for people to express their appreciation through voluntary contributions or tips, on their own terms. This is where platforms like Ko-fi come into play.

In this blog post, I’d like to share a collection of custom shortcodes tailored for Hugo static site generator, designed to seamlessly integrate Ko-fiexternal link buttons and widgets into any blog post. With easy configuration and a range of options to choose from, these shortcodes offer a hassle-free solution for bloggers seeking alternative monetization avenues.

Let’s dive into how you can leverage these shortcodes to enhance your blog and cultivate support from your audience.

Of course if you enjoy it, ☕ me!

Installation and configuration

First, add shortcode theme to your site:

Add kofi shortcodes to Hugo site
cd your-site-location
git submodule add --depth=1 \
    https://github.com/tgagor/hugo-shortcode-kofi.git \
    themes/hugo-shortcode-kofi

All shortcodes rely on one global parameter, which should be set up in your config.yaml or hugo.yaml:

Update hugo.yaml
theme:
  - YourThemeOfChoice
  - hugo-shortcode-kofi

params:
  kofi:
    username: your-name

Thanks to that, you can just use shortcodes without the need to each time provide the user parameter. For more details, check repoexternal link .

Generic parameters

Parameter nameDefault valueDescription
useryour Ko-fi user name, tries to use params.kofi.username first
text"Support Me on Ko-fi"text shown on the button
alt_text"Buy Me a Coffee at ko-fi.com"text shown if image can’t be loaded
color"#29abe0"hex color of the button (if applicable)
style"blue"style of the button (if applicable)
height36height in pixels (if applicable)

Demos

Animated buttons

Those look nice and have animated mugs, but I saw them being blocked by uBlock Origin.

Animated buttonShortcode
{{< kofi/button >}} or
{{< kofi/button color="#13C3FF" >}}
{{< kofi/button color="#FF5E5B" >}}
{{< kofi/button color="#434b57" >}}

Static images

Image style 1Shortcode
Buy Me a Coffee at ko-fi.com{{< kofi/image1 >}} or
{{< kofi/image1 style="blue" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/image1 style="grey" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/image1 style="red" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/image1 style="green" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/image1 style="dark" >}}
Image style 2Shortcode
Buy Me a Coffee at ko-fi.com{{< kofi/image2 >}} or
{{< kofi/image2 style="blue" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/image2 style="red" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/image2 style="stroke" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/image2 style="dark" >}}

Logotypes

LogosShortcode
Buy Me a Coffee at ko-fi.com{{< kofi/logo >}} or
{{< kofi/logo style="logo" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/logo style="mug" >}}
Buy Me a Coffee at ko-fi.com{{< kofi/logo style="pixel" >}}

Badges

BadgesShortcode
Buy Me a Coffee at ko-fi.com{{< kofi/badge >}} or
{{< kofi/badge style=white >}}
Buy Me a Coffee at ko-fi.com{{< kofi/badge style=dark >}}
Buy Me a Coffee at ko-fi.com{{< kofi/badge style=bg-white >}}
Buy Me a Coffee at ko-fi.com{{< kofi/badge style=bg-dark >}}

Dynamic widgets

WidgetsShortcode
check left-bottom corner{{< kofi/floating-button >}}
{{< kofi/donation-panel >}}

Custom images

You can also use your custom images:

{{< kofi/custom height=200 url="https://media.giphy.com/media/kgKFcQk6oa1WIdHNSl/giphy.gif" >}}
Buy Me a Coffee at ko-fi.com

For inspiration check here: