Buy Me a Coffee Button

Hugo Shortcode for Buy Me a Coffee #

Minimal example #

Here is a simple embedded button for getting a donation via the Buy Me a Coffee service:

Buy me a coffee

Code:

{{< bmc-button slug="isqua" >}}

Full example #

You can customize colors and text:

Buy me a milk

Code:

{{< bmc-button
    slug="isqua"
    text="Buy me a milk"
    font="Bree"
    button-color="614484"
    coffee-color="FFFFFF"
    cup-color="FFDD00"
    font-color="FFFFFF"
    >}}

Or use any emoji instead of the cup:

Buy me a croissant

Code:

{{< bmc-button
    slug="isqua"
    text="Buy me a croissant"
    emoji="🥐"
    font="Lato"
    button-color="F5F5EA"
    font-color="C2410C"
    >}}

Parameters #

ParameterDefaultDescription
slugSlug of your Buy Me a Coffee account. You can get it from the URL of your page url on Buy Me a Coffee
emojiIf you don’t want coffee, you can draw some emoji instead of the cup
textBuy me a coffeeThe text on the button
fontCookieThe font family of the button text. See all the available fonts at the Buy Me a Coffee buttons page
button-colorffdd00The color of the button
font-color000000The color of the text
coffee-colorffffffThe color of the drink in the cup
cup-color000000The color of the cup

Site Parameters #

You can set defaults in Site Parameters. For config.toml:

[params.HugoShortcodes.BuyMeACoffee]
    Slug = 'isqua'
    Text = 'Buy me a croissant'
    Font = 'Lato'
    Emoji = '🥐'
    ButtonColor = 'ffdd00'
    FontColor = '000000'
    CoffeeColor = 'ffffff'
    CupColor = '000000'

For config.yaml:

params:
  HugoShortcodes:
    BuyMeACoffee:
      Slug: "isqua"
      Text: "Buy me a croissant"
      Font: "Lato"
      Emoji: "🥐"
      ButtonColor: "ffdd00"
      FontColor: "000000"
      CoffeeColor: "ffffff"
      CupColor: "000000"

Installation #

Don’t forget to install shortcode before usage.

Install all shortcodes at once

If you need dozens of them, it’s better to attach this repository as a theme to your website.

First, add the theme as a git submodule:

git submodule add -b theme https://github.com/isqua/hugo-shortcodes.git themes/hugo-shortcodes

Then add the theme to your config.toml. Most likely you have the following line in your config:

theme = 'ananke'

There may be another theme in place of “ananke”.

Then surround the theme with square brackets, and appends 'hugo-shortcodes' with a comma at the end:

theme = [ 'ananke', 'hugo-shortcodes' ]

That’s it! If your hugo server is running, it is better to restart it to avoid unexpected behavior.

Now you can use all the shortcodes on any content page of your site.


Install only current shortcode

If you need only one shortcode or installing a theme is too complicated, you may get it easier.

That’s it! If your hugo server is running, it is better to restart it to avoid unexpected behavior.

Now you can use the shortcode on any content page of your site.