Skip to content

Extend & Customize HugoBlox

HugoBlox is designed to be extensible. Whether you need a simple CSS tweak or a complex third-party integration, you can do it without modifying the core theme files.

Inject custom code (like analytics, popups, or meta tags) into specific parts of your site using Hooks.

HookDescriptionCommon Use Cases
head-endJust before </head>Meta tags, tracking scripts
body-endJust before </body>Chat widgets, analytics
footer-startInside footerCustom copyright, links

To add a custom script to the end of the body:

  1. Create layouts/partials/hooks/body-end/myscript.html.

  2. Add your code:

    <script>
    console.log("Hello from custom hook!");
    </script>

Override or add new styles.

  1. Create assets/css/custom.css.

  2. Add your CSS.

    assets/css/custom.css
    .my-custom-class {
    color: red;
    }

Hugo’s Lookup Order allows you to replace any official layout file by creating a copy in your local layouts/ folder.

  1. Identify the File Find the file you want to change in the HugoBlox repository.

    • Example: layouts/_partials/components/headers/navbar.html
  2. Copy to Local Create the same folder structure in your site root and paste the file.

    • Example: layouts/_partials/components/headers/navbar.html
  3. Modify Edit your local copy. Hugo will use it instead of HugoBlox’s version.

Use the Blox System to create reusable content blocks.

content/_index.md
sections:
- block: my-custom-block
content:
title: My Block

Create your Go HTML template at layouts/_partials/hbx/blocks/my-custom-block/block.html.

Check out the existing blocks for inspiration.

Listen for theme changes (Light/Dark mode) in your custom scripts.

document.addEventListener('hbThemeChange', (e) => {
const isDark = e.detail.isDarkTheme();
console.log('Theme changed to:', isDark ? 'Dark' : 'Light');
});