Plug-in Shortcode in Site Footer

I’ve added a {{< tinyhits >}} shortcode to my Tinylytics for plug-in. My idea was to have users put the shortcode in their site footer rather than deal with html, but in testing I get the following error on site build:

2023-07-03 16:21:00: Error: add site dependencies: load resources: loading templates: “/jimmitchell-test_876d1b/layouts/partials/custom_footer.html:1:1”: parse failed: template: partials/custom_footer.html:1: unexpected “<” in command

I’ve confirmed the shortcode works in a post. Any thoughts? Is it a scope issue, or something simply not allowed?


The way to do this in plugins is to have an includes in your plugin.json that references the partials (plugin-bigfoot/plugin.json at 0be7b8828f60b4c6a2fccd30430e8f645e904c2a · jsonbecker/plugin-bigfoot · GitHub)

Then their theme, if compatible with plugin usage, will take care of the rest (theme-dailylog/layouts/partials/head.html at main · jsonbecker/theme-dailylog · GitHub).

Tinylytics in this case should not be a shortcode (there’s no parameters, it’s always present) but a partial.

Thanks @jsonbecker. What I’m trying to accomplish is to allow an end user to put a counter snippet as shortcode in the footer of their site (Design > Edit Footer) in the theme section of their site.

If I provide as an include, the counter gets rendered in the page head, and not the page body. The shortcodes for counter and kudo both work as expected when added to a post, but not in the custom footer.

Perhaps I’m not understanding or missing something? I do admit I’m still pretty new to the Hugo framework.

I don’t think Hugo allows shortcodes in partials (the custom footer is basically just a partial). Maybe there could be a partial version of the shortcode that people could use in the footer instead?

This is correct. Your plug-in can provide a partial that they use there, but short codes do not expand in partials.

Thanks @jsonbecker.

Thank you @jsonbecker & @manton. This makes sense now. Appreciate the insights from both of you.