Shortcodes Everywhere

I realize that templates can do a lot and they are currently preferred in cases to create your code. But I am curious if anyone has thot to just allow shortcodes everywhere. Templates. Archetypes and so on.

For instance the Hugo-Theme-Learn has a shortcode called CHILDREN. Which basically creates a similar result to its MENU on the left. I modified it to CHILDREN-HOMEPAGE so that I could get a table of contents for the entire site.

In any case if a short code like that could be called in a template… then I would only have to create the code one time.

In addition, a library of shor codes could be created and used across themes…

like I am going to be downloading all the themes soon and going through and taking all their shortcodes and putting them into a library phor my own use.

When I do that I will update them so everyone can have access.

An example here is the hugo-learn-theme has a SEARCH using LunrJS… and it is great. but it appears to downlaod the same JS data on every page where it is used. My site is a language learning site for a constructed language so it is going to be huge. Thus, I will be removing that phrom every page and just putting it on one page. I will mod the template so that in the front matter oph a page I can say something like search=true… and then a short code phor the actual search itself on he page…

point is… that there could be a lot of places that shortcode could be used… in a template itself… in an archetype… and so on.

as to my project of trying to collaborate all these shortcodes I will keep yall posted.

Yeah, I thought about it and feel the constraint of not allowing it provides better site architecture by way of forcing one to think about how they’re building.

If you want to share code between pages and layouts create a partial and include it in your shortcode. Thanks to @budparr for the suggestion.

so that is basically the same thing in reverse. :smiley: