@DanCouper - Thanks, Dan. Unfortunately it throws me an error saying “isList.includes is not a function”.
I have to edit my problem a bit.
//layout-1 and //layout-2 are actually the same.
What happens now is that the layout shows TWICE for my “normal” tags and also when I have only “isList” tags. This is because my “isList” tags are also included in my “normal” tags.
So I basically need to show the layout only ONCE when it concerns “normal” tags or when it concerns “isList” tags.
Sorry for the confusion.
What is isList? In your code, it’s a function. Do you have, in your code, accessible, a list of all of the pages that have that tag? Or even easier, just a list of tags for the current page:
<% if (pageTags.includes('isList')) { %>
// Do isList stuff
<% } else { %>
// Don't do isList stiff
<% } %>
At the minute, you’re also not doing an else, so there’s no switching going on: it’ll always render twice because that’s what you’re telling it to do: if there’s an isList tag, render the layout. If there’s a tag (any tag), render the layout.
Surely you.know what the tags for the page are, otherwise you can’t do anything, so second solution (put in a list and if (pageTags.includes('isList')) then render