Other Views: By Month | By Category | By Tag Cloud

Hugo - Add Google Analytics

It is really helpful to understand how your site is performing with respect to which posts are getting the most views, how long are people staying on your site, where in the world they are viewing your site from and where did your traffic come from.

To get analytics for this site, I am using Google Analytics which is free.

In this post, we will enable Google Analytics on our Hugo site.

Read More

Hugo - Set Default Front Matter When Creating Post

Did you know that when you create a new post in Hugo that you can set the default front matter set for you?

I didn’t know either until after I had done over 50 posts where I created all of my posts files and front matter by hand. Whereas I could have had Hugo create the files for me and set default front matter that I wanted.

In this post, we will look at how you can also set your default front matter for your post.

Read More

Git: Delete Merged Local Branches That No Longer Exist with Powershell

Previously, I wrote about how to delete git branches that have been merged and no longer exist on the remote using git bash. Using git bash worked just fine for this. However, my normal shell is PowerShell and I want to stay in PowerShell.

In this post, we will look at how to use PowerShell instead to delete your local git branches that have been merged and no longer exist on the remote.

Read More

Hugo - Dynamically Add Copy Code Snippet Button

I have many posts on this site that include code snippets for the reader to cut and paste into their code. From a usability perspective, instead of always making the user select lines from the code snippet to copy and paste, we can add a copy button to the code snippet.

example without line numbers:

copy button example

example with line numbers:

copy button example with line numbers

This post will look at how to implement the copy button, as you see in the above images, any time that we detect a code snippet on a post.

Read More

Hugo - Add Preview When Sharing to Twitter

When you share your blog post on Twitter, you can attach photos, videos and media experiences to Tweets, which helps to drive traffic to your site.

This is called a Twitter card and looks like:

twitter card example

There are two types of Twitter Cards that we are concerned with for our site

  1. Summary Card: Title, Description, and Thumbnail (optional)
  2. Summary Card with Large Image: Similar to the Summary Card but with a prominently featured image

Read More

Hugo - Add Contact Form Using Formspree

When creating your blog, it is a good idea to have a contact me form. With static sites though you do not have server side processing available to send you an email with from the contact me form submission.

To overcome not having server side processing available, we are going to use Formspress.

Formspree is free for up to 50 submissions per month.

Read More

Hugo - Create a 404 Page

Every website should have a 404 page for when a user tries to go to a page that does not exist.

Hugo out of the box does not provide you with a nice 404 page but we can create a 404 page just like any other page. Creating the page though is the easy part. The hard part is getting the 404 page to display when a user goes to an invalid url as it depends on your website host to set up the 404 page redirect0000.

For this site, I am hosting it using Netlify and they automatically pick up my 404 page.

Let’s take a look at how to create our 404 page.

Read More

Hugo - Minify JS and CSS

When you think about a website’s performance, you should minify your CSS and JavaScript file so that they download as quickly as possible. This still holds true even with static sites like Hugo. Luckily, Hugo can minify files out of the box using what Hugo calls Asset Pipeline.

In this post, I will show you how to take advantage of the Hugo Asset Pipeline to minify your CSS and JavaScript.

Read More

Take your Windows Terminal and PowerShell to the next level

I was watching the Bald Bearded Builder, Michael Jolley, and I had shell envy as I watched him use PowerShell terminal. His terminal showed the git status, node version, folder/file icons, cool color scheme, and predictive completion when typing commands based on his PowerShell history.

Michael’s PowerShell Terminal

I asked Michael in chat if he would be willing to share his PowerShell profile which he was nice enough to do right then and there on stream.

However, even with his PowerShell profile in hand, it still took me a bit of time to figure out what I needed to do to take advantage of the profile.

Let’s walk through the steps I took to get my she’ll working like Michael’s.

Read More

Hugo - Integrate Google Search

As your site content grows, finding content will become harder and you will need to add the ability to search your content.

You could create your own client search using something like lunr.js but then you have to maintain the search code and deal with any issues that come up. To me this is a distraction from the real goal of publishing content on your site.

So instead, I prefer to harness the power of Google to search my site using the handy search argument site: to tell Google to just search my site for the search term.

In this post, we are going to create a search page that will take the reader to Google for the search results.

Read More