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.
| Hook | Description | Common Use Cases |
|---|---|---|
head-end | Just before </head> | Meta tags, tracking scripts |
body-end | Just before </body> | Chat widgets, analytics |
footer-start | Inside footer | Custom copyright, links |
- Create the hook file path.
- Add your HTML/JS code.
Example: Add a Script
To add a custom script to the end of the body:
-
Create
layouts/partials/hooks/body-end/myscript.html. -
Add your code:
<script> console.log("Hello from custom hook!"); </script>
Custom Styling (CSS)
Override or add new styles.
-
Create
assets/css/custom.css. -
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.
-
Identify the File Find the file you want to change in the HugoBlox repository.
- Example:
layouts/_partials/components/headers/navbar.html
- Example:
-
Copy to Local Create the same folder structure in your site root and paste the file.
- Example:
layouts/_partials/components/headers/navbar.html
- Example:
-
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?
Delete a Site
How to remove your site from your local machine and hosting providers.
Contributing to HugoBlox
Help improve HugoBlox. Guide for contributing code, documentation, and ideas. Join the community on Discord and GitHub.
From the makers of
© 2026 Lore Labs.