diff --git a/gulpfile.js b/gulpfile.js index d655398b..b2c620fa 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -81,6 +81,12 @@ gulp.task('clean', function () { del.sync('./output_*/assets/fonts/*'); }); +gulp.task('minify-prod-html', function() { + gulp.src('output_prod/**/*.html') + .pipe(plugins.htmlmin({ collapseWhitespace: true })) + .pipe(gulp.dest('output_prod')); +}); + gulp.task('build', ['clean', 'styles', 'scripts', 'fonts']); gulp.task('default', ['build', 'watch']); diff --git a/package.json b/package.json index 26126d87..60e360da 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "del": "^2.2.0", "gulp": "^3.9.0", "gulp-concat": "^2.6.0", + "gulp-htmlmin": "^1.3.0", "gulp-if": "^2.0.0", "gulp-imagemin": "^2.4.0", "gulp-livereload": "^3.8.1", diff --git a/publish.sh b/publish.sh index 4c56f71a..4ba50c83 100755 --- a/publish.sh +++ b/publish.sh @@ -11,5 +11,8 @@ gulp build --production ./vendor/bin/sculpin generate --env=${ENV} --clean --no-interaction if [ $? -ne 0 ]; then echo "Could not generate the site"; exit 1; fi +# Minify HTML. +gulp minify-prod-html + rsync -av --delete output_${ENV}/ ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH} if [ $? -ne 0 ]; then echo "Could not publish the site"; exit 1; fi diff --git a/source/_layouts/default.html.twig b/source/_layouts/default.html.twig index c375a6e4..f33622d8 100644 --- a/source/_layouts/default.html.twig +++ b/source/_layouts/default.html.twig @@ -99,15 +99,7 @@ {% endif %} {% if site.google_analytics_tracking_id %} - <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', '{{ site.google_analytics_tracking_id }}', 'auto'); - ga('send', 'pageview'); - </script> + <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', '{{ site.google_analytics_tracking_id }}', 'auto'); ga('send', 'pageview');</script> {% endif %} </body> </html> diff --git a/source/blog.html b/source/blog.html index 086f49dd..926dbd35 100644 --- a/source/blog.html +++ b/source/blog.html @@ -19,7 +19,7 @@ use: {% if post.blocks.excerpt %} {{ post.blocks.excerpt|raw }} {% else %} - <p>{{ post.blocks.content|raw|split(' ')|slice(0,50)|join(' ')|replace({ 'h2':'h3' })|raw }} …</p> + <p>{{ post.blocks.content|raw|striptags|split(' ')|slice(0,50)|join(' ')|replace({ 'h2':'h3' }) }} …</p> {% endif %} <a href="{{ post.url }}">Read more →</a>