This post is about loading your CSS files with Hugo in an easy and efficient way, now that Hugo has asset and minification built-in. The advantages of using the functions that come with Hugo are that you don’t have to do any of the building yourself (or use a third party), it just does it!
There are a few steps involved in the code that we will walk through:
Specify your main scss filename (the one where everything imports into).
Specify your outputted filename.
Define your options, if you are on a local server then we turn on source maps (for easier debugging), otherwise we minify the CSS for performance on our live environment.
Note: the hyphen in {{- means remove all whitespace before this.
This will output something like:
1
<linkrel="stylesheet"href="/css/style.css">
Verify Authenticity (optional)
If you think there’s a possibility of your CSS being tempered with and you want to be extra careful then you can check it’s integrity by using the “fingerprint” option. To do this, change the last 2 lines to look like this:
Edd is a PHP and Go developer who enjoys blogging about his experiences, mostly about creating and coding new things he's working on and is a big beliver in open-source and Linux.
Changing the Syntax Highlighting Style in Hugo
–
When building a website using Hugo, you might want to customize the syntax highlighting to match your site’s overall aesthetic. Hugo uses Chroma, a powerful syntax highlighting engine, to provide code highlighting out of the box.
In this blog post, we’ll guide you through the process of changing the syntax highlighting style in Hugo using Chroma, with the help of the hugo gen chromastyles command.
Thumbnail Images on your Hugo Blog Posts
–
Hugo now has the ability to do image resizing, cropping, quality-changing, etc (hooray!) - so how do we use it? In this post we take a look at how to resize images automatically using Hugo. There’s a few different ways to achieve this, depending on what you’re trying to do.
In a Theme - “I want to make thumbnails!” You might run a blog, which on the home page has a list of your blog posts.
99+ Google Pagespeed Score with Disqus
–
If you’re into your front-end web performance you will probably have heard of Google Pagespeed and/or Lighthouse as tools to test and measure how quickly and efficiently you web pages load. This is also something we use here on this site to make your reading as pleasant as possible.
But, we also use the online commenting system called Disqus and the two don’t always play nicely together - in that Disqus loads lots of files and takes a while to load.