I want to create a custom hooks system like WP from partials in different parts of my reusable theme, instead of copying files from theme to root for every site and making edits there. Is that an anti-pattern?
{{- if templates.Exists "_partials/hooks/before-head.html" }}
{{- partial "hooks/before-head.html" . }}
{{- end }}
Then I could just create such a partial at the root to hook into the theme.
In my opinion not. And I have created an extremely overenginered such system myself
The main idea is that you could “plug in” whatever you want at specific points. If the user wants to use a Github discussions based comment system, or a DISQUS based one, let them do that. Look for a discussion hook and let it have the post data. If the user wants an Ad between post 1 and 2 - hook it in. Add a hook for analytics scripts in the header, add a hook for stuff in the footer.
You give your users the option to extend your theme without overriding the theme on updates. As long as you keep the hooks existing and/or find a way to anounce anything missing or wrong configured on CLI.
In my case I have a couple of modules that do stuff in the head tags of a website. The hooks look if these modules are there and plugs the tags in.
If you look at it from the WP point of view, you can even do filters. Hand something over to the partial and let it return the parsed content.
Example again: German language I sometimes filter text through a umlaut-filter. Or you have a tagline/subheading and want it to generate some random text. Send the text to a filter-partial and use what it returns in a variable.
Long story short: anti pattern? probably not. potential for excessive OCD traps? totally.