I have only been using Hugo only for a couple of days now and
pardon me if this is a dumb question.
I have a shortcode which defines a product name. It’s referenced
in a lot of places and it works as expected in content
files. However, when I use it within a string parameter of
another shortcode, as. in “How to install {{product_name}}”, and
it was rendered literally - no substitution of the value.
Here is some of the relevant code (simplified).
product_name.html
<span>Acme Tools</span>
article.html
<a href="{{ .Get 1 }}">{{ .Get 0 }}</a>
Usage:
{{< article "How to install {{product_name}}" "/articles/howto/install/{{product_name}}" >}}
After much searching, I came to the conclusion that shortcode
parameters can’t refer to any shortcodes. They can be either
plain string, html or something markdownify accepts. Finally, I
ended up using replace, just as mentioned in the thread
Parameterizing some parts of the content seems like a legitimate
requirement and shortcode the obvious answer. My question is, I
don’t have enough knowledge of Hugo and wondering if I am missing
something here or just using the wrong approach. Using replace
seems pretty hacky to me and I would like know how others handle
such requirements.
Thanks,