How can I prevent people accessing templates directly that are only used as includes for instance?
I read that I could add an underscore ie _example.html,but then the include stops working.
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityHow can I prevent people accessing templates directly that are only used as includes for instance?
I read that I could add an underscore ie _example.html,but then the include stops working.
If your template is _example.html, you include like this:
{% include '_example.html' %}
It also works to have a template in a directory that starts with an underscore. So you could name the directory _includes, name the template in there example.html and include it like this:
{% include '_includes/example.html' %}
Either way, the template can't be accessed directly.