Newb user here. I’ve seen some hints here and there throughout the forum but never anything definative.
What I’d like to do is build a custom library of routines and functions that I can use.
For example I might want to take the date that I create a page (say 2025-05-15) convert it directly to a “number” (20250515) and then convert that from base 10 to base 36 (c21eb)
Such as you can do here:
Is this something I could conceivably do as a shortcode or module?
Hello, it seems to me that such calculators are easier to make in JavaScript, which can then be embedded into a separate template for a specific Hugo page (since it won’t be used anywhere else except there).
Well for example the calculator above. I actually use that to generate internal links on some websites (anchors within a page). Only now I have to do the calcs manually.
So for me if this is something that I could build into my HUGO processing great - a custom shortcode or function I can call at “compile” time.
The Hugo equivalent of a custom function is a partial template that returns a value instead of rendering something. Within the partial template you can call any of Hugo’s built-in functions and methods.
Note the only relevant encoding function is for base 64, but one of the non-crypographic hash functions might be useful as well. Of particular note is the xxHash function which is really fast.
We add new built-in functions from time to time. If there are one or two things in particular that we’re missing, and that are simple to implement, document, and support, make a suggestion.