How to Add Custom HTML Code to Your Hugo Website

Mansoor Barri
Nov 13, 2023

--

Create a new shortcode

To use the rawhtml shortcode, you’ll first need to create a new shortcode file in your Hugo project. You can create a new shortcode file in the layouts/shortcodes/ directory. For example, you can create a file called rawhtml.html in the layouts/shortcodes/ directory.

In the rawhtml.html file, add the following line:

{{.Inner}}

Usage

Now you can put your HTML within rawhtml shortcode for example the comments section for this post is present using a <script> tag. Code example:

that’s it | get access to latest posts earlier on https://mansoorbarri.com/

--

--

Mansoor Barri
Mansoor Barri

Written by Mansoor Barri

Profile designed to share technology content about Penetration testing, Linux and Windows.

No responses yet