How to add a new social media link to Minima 2.5.1 and latest unreleased version (3.0.0)
Recently I migrated all of my Jekyll sites from Minima 2.5.1 (updated August 2019) to the latest version on GitHub (updated January 2023). This came with lots of new features, but also changed how social links are handled. In this post I’ll cover both the old and new method for adding new social links, as well as the technical details.
Before we get started, here is the Minima 2.5.1 sourcecode, and here is the latest source code. Minima inexplicably hasn’t had a new release in over 3 years, so the latest codebase has diverged from the latest release.
Which Minima version do I have?
If you’ve just set up your Jekyll blog, you have Minima 2.5.1.
If you’ve manually set remote_theme=jekyll/minima
in your _config.yml
, you have the unreleased Minima 3.0.0.
Adding social link in Minima 2.5.1
Adding a new social link is pretty straightforward, but there’s no official guide! You can see an example of this process in a commit from when I added a Substack link to my site. Note that the SVG is minimised (all on one line), but you can still see the <symbol>
.
Steps
- Get an SVG.
- In this example I’ll use FontAwesome’s “coins” icon, obviously make sure you have permission to use your SVG!
- Change the SVG into a named symbol.
- Add SVG to combined image.
- Add social link to footer.
- Inside
social.html
, copy an existing line (e.g. YouTube) and replace the URL & variable names (e.g.youtube_username
tocoins_username
). - Don’t forget to update the
minima-social-icons.svg#youtube
to your ID from step 2.
- Inside
- Add to
_config.yml
.- For example, these coins might be
coins_username: Jake123
andcoins_url: https://example.com/Jake123
.
- For example, these coins might be
- Relaunch your site, your new social link should be there!
Explanation
Whilst the process of adding a new social icon to Minima 2.5.1 is pretty convoluted, at least the use of it is simple!
footer.html
includessocial.html
.social.html
checks each social source to see if it is defined in_config.yml
, and displays the username & URL if so.- Additionally,
social.html
uses thesymbol
’sid
to fetch a specific section of theminima-social-icons.svg
, e.g.#youtube
.
Adding social link to latest Minima
Whilst there is a guide on the project’s readme, it can be a little tricky to know how to resize the image and handle it correctly.
Steps
- Get an SVG.
- In this example I’ll use FontAwesome’s “coins” icon, obviously make sure you have permission to use your SVG!
- Resize to be 16x16 square.
- I used “iloveimg”, but if you have a proper SVG editor feel free to use it.
- Set the width & height px to 16 (since SVGs are scalable there won’t be any loss of quality) then download.
- It’s OK if it’s not square by a pixel or two, but it’s worth the effort if possible!
- Remove everything except
<path>
data.- Open in any text editor.
- Check inside the
<svg>
element forviewBox="0 0 16 16"
, this means it’s the correct size. - Delete everything outside of the
<path>
tag, and thestyle=" ... "
bit, then save.
- Put this SVG in
_includes/social-icons/
. - Add to
_config.yml
.- For example, these coins might be
- { platform: coins, user_url: "https://example.com/mycoins" }
- For example, these coins might be
- Relaunch your site, your new social link should be there!
Explanation
Minima 3 changed how social icons are used. Instead of being manually added into one big SVG, they are now dynamically built up during compile time.
Personally I think this is overly convoluted, and would be better served by just displaying standard SVG icons, or using the slightly simpler previous system. The justifications in the PR do make sense, but for a “minimal” theme it’s a totally unnecessary complication (as was the previous system). Adding a new clickable icon shouldn’t include this much complexity:
Generating the combined SVG
minima-social-icons.liquid
loops through thesocial_links
defined in_config.yml
, and includessvg_symbol.html
once per social link.svg_symbol.html
builds up a 16x16 section of the overall SVG, including the social link’s icon by name.
Using the combined SVG
_includes/footer.html
(the site’s footer) includessocial.html
.social.html
loops through thesocial_links
defined in_config.yml
, and includessocial-item.html
once per social link.social-item.html
looks in theminima-social-icons.svg
file for an SVG with the social link’s name, and displays a clickable icon.