Hugo ignores shortcode overrides

Hi all,
in my theme there are a few shortcodes and I would like to override one (or more) of them by creating my own layouts/shortcodes/myshortcode.html
The docs Create your own shortcodes say hugo will lookup the following folders in order:

  1. /layouts/shortcodes/<SHORTCODE>.html
  2. /themes/<THEME>/layouts/shortcodes/<SHORTCODE>.html

I would expect that if I create /layouts/shortcodes/ABC.html, this would take priority over /themes/<THEME>/layouts/shortcodes/ABC.html
In my case this is just not working. hugo version out put is:
Hugo Static Site Generator v0.75.1-A4A7BAB7 linux/amd64 BuildDate: 2020-09-15T06:46:04Z
Am I just doning something wrong or am I wrong in expecting this behaviour? In my opinion this should be possible.
Thanks all.

Yes, you’re right. /layouts/shortcodes/ABC.html will take preference over /themes/<THEME>/layouts/shortcodes/ABC.html

1 Like

You answered too fast :slight_smile: I edited the answer. In my case it’s not working. shortcode overrides are ignored.

Well, it should have worked. However, you do have 2 options. Either create a shortcode with a different name, or, edit the one in the theme.

If you don’t mind sharing a simple demo source code of your problem, maybe, I or someone else can take a look.

Regarding source: I wish but I can’t at the moment. But I found that using the --disableFastRender option stops this from happening. Hugo now reacts when I change the shortcode override.

Great to know you got it working!

1 Like

But all in all your idea of just giving it a different name is what I went for in the end. It just makes more sense and makes the code flow clearer.
Still, I’d be keen on knowing if anyone else or the devs can reproduce this.

1 Like