If possible, I’d like to get an explanation of some unexpected behavior (at least to me) that I’m seeing with the new templates system, based on this change:
_shortcodes and _markup directories can be added to any level in the file tree.
Given the following structure (note that I’m only showing relevant files)…
Error: error building site: process: readAndProcessContent: ".../content/section1/_index.md:9:1": failed to extract shortcode: template for shortcode "badge" not found
If I want the badge shortcode to only be available in section1, it seems like I still need to put an empty badge shortcode in the base shortcode directory to prevent the error.
Why is this? Am I not understanding the intent of this change? Am I getting this error because render hooks have an internal default, and my custom shortcodes do not?
Can you provide a link to where the _shortcode directory is introduced? I missed that somehow and the docs don’t have it (yet). Also the “any level of the file tree” thing is new to me. That would have had to be a bigger announcement I think. Maybe it’s a feature that is still to come?
Based on this I would expect your setup to work. It makes it hard to argue for subfolder _shortcodes to have a base folder version they have to override (or the other way around). This might be a bug and just not yet covered with a test case.
On the other side, there is no explicit comment about shortcodes inside of your section1 only being available inside of section1 - I don’t think that would be an intended feature.
Just my two cent, sorry for wasting your time, but I am interested in how this turns out too
Yes, you are right, this is certainly a leap I made in my mind. I suspect that this is not a bug, but with the new templates, you can only override a base-level shortcode from a lower level.
I’ve had situations where it would be desirable to have a shortcode only available in a certain section, which previously I could handle with template logic, but I was just excited about the possibility of it being built-in.
Maybe you have the shortcode used somewhere outside of that section? Or maybe the shortcode is in a page where your frontmatter changes something about the used template for the page, thus “moving” out of section1?
Also, just using myshortcode.section1.html is interesting in that I can call {{< myshortcode >}} from any section of the site. I find that confusing too, haha.
Oh well, I should probably just wait for the official docs.