Answer the question
In order to leave comments, you need to log in
How to correctly create reusable sections in Pug (jade) connected via include on multi-page sites?
On the screenshots, the page-preview block is highlighted, which changes on different pages of the site (the text, design, etc. change). I created a separate _page-preview.pug file, in which I described the markup of this block for the blog page:
section.page-preview.page-preview_dash.container
h2.page-preview__title Our Blog
p.page-preview__text.
Here's where we address the burning questions. From new tech, creative inspiration and new business wins to movie reviews. It's all here in our journal.
Answer the question
In order to leave comments, you need to log in
Mixins are the best option. Look at another version of the mixin, you can have 10 parameters, in the final version you just specify +block({modify: 'myclass', title: 'mytitle'}) and it turns out that out of 10 parameters only 2 will be used.
You can also use it with _page
-preview.pug includes
section.page-preview.page-preview_dash.container(class= MYSUPERCLASS)
h2.page-preview__title= MYSUPERTITLE
p.page-preview__text.
Here's where we address the burning questions. From new tech, creative inspiration and new business wins to movie reviews. It's all here in our journal.
- var MYSUPERCLASS = 'pumpum';
- var MYSUPERTITLE = 'tarampampam';
include _page-preview
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question