Organization of shortcodes

It is possible to arrange my shortcodes with arbitrary directory structure, e.g., i would like to create shortcodes in a directory structure to correspond with the post, e.g., under layouts/shortcodes/post/post-title/shortcode1.html. This is for organizational purposes.

is there a better or another way to achieve this?


As far as I know, this isn’t possible. But it’s easy to test: just move a shortcode to /layouts/shortcodes/testdir/ and see if referencing the shortcode in the content file still works.

Not sure if you intend to organise shortcodes like this, but just to prevent confusion/miscommunication: you know that shortcodes are typically used for needs that arise in multiple posts? That is, you’d use a generic shortcode for inserting an image but won’t create a specific shortcode for each post (in the majority of cases).

If you have specific code that should only generate for that particular post title, it’s probably easier to just include that code in your content file.

Thanks for the clarification.

I am a relative new user. I was using partial html templates which I can create in the layout/partials parth …

The use case for shortcode is mentioned is appropriate actually. For my case, I was using it to automatically add figures that are embedded in tags so they are clickable too. I guess I could do this for other posts and hence can place the shortcodes appropriately.

For the test moving the shortcodes, I tried it before asking (to see if a better way). It doesn’t work at least for me.