Shortcode in HTML file which is located in content


#1

Just found out the following:

Beside some Markdown files I have an HTML file in my content which by default uses the template layouts/_default/single.html. I tried to put a partial directly in the HTML file (like {{ partial "partial-name" . }} which did not work. But then I tried to call a shortcode in the HTML file (like {{< shortcode-name >}} and call the same partial like above inside the shortcode and that works.

Nice. Perhaps this is something for you.


#2

I always appreciate sharing workarounds, thanks!

I’d like to point out this may not be the first step to “fixing” this issue. If your partial isn’t working in a template, it is better in the long run to know why, ne? This sounds like it could be a scoping issue or something. Feel free to open a support ticket with this specific issue, I bet we could figure it out. :slight_smile:


#3

I was not talking about a partial in a template. I was talking about a partial in an ordinary HTML file which lives in the content folder beside some Markdown files.


#4

The gist of this is that

  • HTML files in /content IS a content file. Shortcode support and all.
  • If it has front matter, it will get the same template handling logic as the rest.
  • If it does not have front matter, it will be its own template.

The last one is a little magical, but we have had it so long so removing it would break glass houses.


#5

So that last one… would that be good for landing pages? or not recommended?