Checking for a Shortcode's Existence

How can I check if a specific shortcode is used on a page? I often want to only include specific JS/CSS files in the header if their corresponding shortcode is used on that page. How can I achieve that?


.HasShortcode “myShortcode”

1 Like

Wow, great. Thanks!

I wonder why I can’t find this in the documentation?

Probably because I was too lazy or forgot to add it. But you can find it in Hugo’s GoDoc:

1 Like

That said: This is an open source project, so an addition of that method to the docs would be welcomed.

I’ve added it: