I’m a long-time Drupal user and am used to the idea of ‘hooks’ or event listeners that allow you to add your own scripting to be run at different points when the main program is run. For example, in Hugo I’ve wanted to modify the output of all template files when they’re used to render content - something I could do in Drupal - but as far as I can tell, there’s no way to do that in Hugo.
Is there anything like a ‘hook’ system in Hugo? If not, is that something that’s ever been discussed or is being considered?
Nope, there’s not. A plugin feature has been discussed earlier, and here is a discussion about things like registering external functions (which might match what you’re looking for with hooks).
To summarise what I remember from seeing the discussions:
- Opening up Hugo to plugins and other custom code increases the workload and maintenance work of the Hugo team.
- Might give a more negative experience to users (slower Hugo, people needing to install extensions before a particular theme can be used).
- Organisational issues (things like, how to ensure people use the right function if a theme relies on them).
- Plugins have the potential to reduce the security of Hugo.
- And looking at the discussion about the possible
exec shortcode: difficult to understand for non-developers (so documentation challenges).
(I’m not saying I’m against plugins or hooks, but just to recall here the points that I remember from previous discussions and issues on GitHub.)
Thank you, @Jura, I appreciate the pointers to those discussions. I can see the advantages to both approaches. I know that in the Drupal world, having a rich set of hooks has allowed for a greater depth and growth in the community, which I believe over time has helped to offset the additional cost of support.