Maintenance

Extend & Customize HugoBlox

Extend HugoBlox functionality. Use Hooks to inject code, add custom CSS/JS, override components, and develop custom Blocks for your site.

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.

Hooks

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
  1. Create the hook file path.
  2. Add your HTML/JS code.
custom-meta.html
analytics.html

Example: Add a Script

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>

Custom Styling (CSS)

Override or add new styles.

  1. Create assets/css/custom.css.

  2. Add your CSS.

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

Overriding Components

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.

Only override files if absolutely necessary. You will need to manually update your overrides when HugoBlox updates.

Try to use the Hooks, Styles, or Plugin system instead. With the Plugin system, you can create new blocks and listing views.

Advanced Customization

Creating New Blocks

Create custom blocks using Go HTML templates or Preact components, with optional co-located style.css for Tailwind-powered styling.

See the full Block Development guide for details on both approaches.

Theme-Aware JavaScript

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');
});

Was this page helpful?

From the makers of

© 2026 Lore Labs.

On this page