Here’s a nice example of the kind of ridiculous I must embrace when writing Hugo code (f$&k I miss Swift). What you are looking at is a simple check for the use of a pair of shortcodes (hacked to f$&k so it works on the homepage, taxonomy pages, and single pages).

cc @sod

Sven Dahlstrand

@Moondeer Wow, that's one impressive – and kind of intimidating – piece of code. 😅

Jason Cardwell

@sod I found discussion of the problem on a forum or I'd never have known WTF the problem was. With list pages you have to check every page in the list … and … for whatever reason … on the home page you have to go a layer deeper.

Sven Dahlstrand

@Moondeer I probably lack too much context here, but judging by the comment at the bottom, you're including stylesheets based on if a shortcode is used or not. Is that right? Could an alternative be to just always have the stylesheet? That way, you could just get rid of the entire if/else block.

Jason Cardwell

@sod yeah, this one is trivial and I kinda just wanted to test it out … it was a bigger deal when Javascript was also being injected.