Hugo Open External Links in a New Tab

The default behaviour in Hugo is not open a new tab for external links. This little snippet does the trick using render hooks. It looks complicated unless you have a basic understanding of the go templating packages Create a new file layouts/_default/_markup/render-link.html and add the below. Thats it! <a href="{{- .Destination | safeURL -}}"{{ with .Title}} title="{{- . -}}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="nofollow noopener noreferrer" {{ end }}>{{- .Text | safeHTML -}}</a> References Hugo: open external links in a new tab

May 30, 2025 · 1 min · Dinesh Auti

Hugo Line Break

By default, Hugo does not render the <br /> HTML tag for line breaks. To insert a line break in your content, add two spaces at the end of a line.

May 28, 2025 · 1 min · Dinesh Auti

Hugo Starter Setup

Base setup for Hugo with PaperMod theme After a few hours of tinkering, I finally have a basic Hugo blog setup with the PaperMod theme. Love the theme’s simplicity and responsiveness. Here’s a quick rundown of the setup process: Install Hugo: Follow the Hugo installation guide to get Hugo up and running on your machine. Create a new site: Run hugo new site myblog --format "yaml" to create a new Hugo site. Add the theme: Clone the PaperMod theme into your site’s themes directory: git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod Start the server: Navigate to your site directory and run hugo server -D to start the local development server. Thats all! You can now start creating content in the content directory and customize your site using the theme’s configuration options. ...

May 27, 2025 · 4 min · Dinesh Auti

Hugo Homepage Mainsections

You can control which sections of content appear on your Hugo homepage using the mainSections setting in your site configuration (config.yaml or config.toml). By default, Hugo may show all posts, but specifying mainSections lets you limit the homepage to specific sections. For example, to display only posts from the posts and til sections, add the following to your config: mainSections: ["posts", "til"]

May 26, 2025 · 1 min · Dinesh Auti