Skip to content

Add page-based content with Nunjucks variables #1922

Answered by pdehaan
Brixy asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure if I follow 100%, but I don't know if that will work (although admittedly I haven't tried building it locally yet). I think my main concerns would be that pageHeader gets set, and then added to the page using {% include "meta.njk" %}. Then we overwrite the local pageHeader variable w/ page header 2 content and add another <header class="page-header">{{ pageHeader | safe }}</header> to the DOM. So far so good, but you'll have two <header class="page-header">s on your page. But now when you get to the footer, I assume your pageHeader variable from earlier is still in scope, so your footer might have the following:

<header class="page-header">
  My page header 2 content.
</header>

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@pdehaan
Comment options

pdehaan Aug 7, 2021
Collaborator

Answer selected by Brixy
Comment options

You must be logged in to vote
4 replies
@pdehaan
Comment options

pdehaan Aug 7, 2021
Collaborator

@Brixy
Comment options

@pdehaan
Comment options

pdehaan Aug 8, 2021
Collaborator

@Brixy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants