D
D
DeniSidorenko2017-07-29 21:40:47
HTML
DeniSidorenko, 2017-07-29 21:40:47

How to split HTML in GULP?

Hello, I use the layout for work from the famous author WebDesignMater
https://github.com/agragregra/optimizedhtml-start-...
Excellent assembly, everything works perfectly, only now there was a desire and a need to separate the layout of the page. That is, through include footer, header, sidebar, etc. Please tell me the plugin for gulp and how to configure it. Google seriously climbed, installed 2 plugins, but either they don’t work correctly or something else doesn’t work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2017-07-29
@DeniSidorenko

I think that you are asking about gulp-rigger
, for example, we write repeating header and footer
in our index.html (and on all similar pages):
at the same time, we create header.html and footer.html in the template folder
and on the compiled page you will get a complete page with the code, you will not need to repeat it again and again on each page
UPD: a complete example of using the plugin,
create a template folder in the project, in it the files that we will include, for example, header.html and footer.html, install the plugin:

var rigger = require('gulp-rigger');
создаем таск:
gulp.task('html', function() {
    gulp.src(src.html)
        .pipe(rigger())
        .pipe(gulpIf(env !== 'dev', minifyHTML()))
        .pipe(gulp.dest(outputDir))
        .pipe(connect.reload())
});

write in index.html
and everything works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question