In need of a simple landing pages or static websites? Then this extremely minimal Modern HTML5 Boilerplate might be just for you.
- Produces minified, static HTML files
- Automatic JS/CSS minification, uglify, combine, compress and concat with Gulp
- Stylesheet language: SCSS (libsass)
- Flexible SCSS grid included: Jeet Grid
- Responsive typography with viewport units
- SCSS and PHP linting built-in
git clone https://github.com/ronilaukkarinen/modern-html5-boilerplate yourprojectname
- If you add your project to git, remember to remove
.git
folder withrm -rf .git
npm-check-updates -u
to update Node.JS modules (you need npm-check-updates for this)npm install
to install them- Edit
package.json
andgulpfile.js
and rename project name and author according to your new project gulp
and start coding your static website (you might want to change meta tags and_config.scss
variables first)
Start with src/sass/layout/_main.scss
.
Have fun!
Currently this produces static HTML pages via php2html, but you can disable gulp-php2html, gulp-htmlmin and enable semi-dynamic caching for your index.php, by adding this to dist/index.php:
<?php
// Settings
$cache = false;
$cache_lifetime_hours = 12;
$minifyhtml = true;
$cachefile = 'index.html';
// Minify HTML -function
function sanitize_output( $buffer ) {
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\</s', // strip whitespaces before tags, except space
'/(\s)+/s', // shorten multiple whitespace sequences
);
$replace = array(
'>',
'<',
'\\1',
'',
);
$buffer = preg_replace( $search, $replace, $buffer );
return $buffer;
}
ob_start( 'sanitize_output' );
// Start cache tricks
if ( $cache === true ) :
$cachetime = 3600 * $cache_lifetime_hours;
if ( file_exists( $cachefile ) && time() - $cachetime < filemtime( $cachefile ) ) {
echo '<!-- Amazing hand crafted super cache by rolle, generated ' . date( 'H:i', filemtime( $cachefile ) ) . ' -->';
include( sanitize_output( $cachefile ) );
exit;
}
ob_start();
endif;
// Content start
include('../src/index.php');
// End cache tricks
if ( $cache === true ) :
$fp = fopen( $cachefile, 'w' );
fwrite( $fp, sanitize_output( ob_get_contents() ) );
fclose( $fp );
ob_end_flush();
endif;