Answer the question
In order to leave comments, you need to log in
What is the correct way to use blocks in Jade layout?
Good day! Recently started using Jade. At first everything was fine, but then I began to think about the correctness of my actions.
The essence of the question is this: how to use blocks correctly, name them and structure them?
I'm starting to type up the index, I have a block _about.jade, _contact.jade and so on. I connect them via Include and all is well. In fact, the main page is a brief description of the entire corporate site. But then I start to typeset the about.jade page and I understand that I already have such a block. Somehow I misunderstood the essence of the blocks ... And I don’t know how to name the blocks correctly, maybe something like _index--about or create a separate folder with blocks on each page, or it turns out not to be a block at all if I only use it on the home page?
Structure at the moment:
prntscr.com/a5ptax
Все блоки сейчас созданы для главной странице
Сайт не большой по сути, 5 страниц. Можно было все сделать без блоков, но мне хотелось бы понять саму суть
Answer the question
In order to leave comments, you need to log in
IMHO, only what is clearly used in several places should be put into blocks. Otherwise, you will end up with a bunch of files that are only used once.
There are also mixins. I recommend reading about them. The bottom line is that if several pages have similar blocks with a slight difference, mixins will allow you not to duplicate the main code.
Look here https://github.com/zoxon/gulp-front
Pages in the source/pages
folder Blocks in the source/modules folder
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question