alanorth / hugo-theme-bootstrap4-blog

A blogging-centric Bootstrap v4 theme for the Hugo static site generator.
Other
204 stars 132 forks source link

uses html-minifier, by default --preserve-line-breaks to keep code re… #126

Closed Jieiku closed 4 years ago

Jieiku commented 4 years ago

cd ~/hugo/mysite/themes/hugo-theme-bootstrap4-blog npm install html-minifier

html-minifier, by default --preserve-line-breaks to keep code readable, can be further minified if that parameter is removed.

Please look it over to make sure its ready for the masses. This is working great on my site for cleaning up the html source code.

OH! Also after running npm run build and hugo -D next I overwrite the contents of /public with /public-out overwriting the original files with minified files.

Jieiku commented 4 years ago

build check is failing because ../../public does not exist unless this theme is part of a hugo site. So im not sure if this could cause an issue on a fresh install, possibly it could, maybe the solution would be to have it create ../../public prior to running the html build. Then it would not matter.

I am not sure what would be best to do on this one, so I will wait for your input. Let me know what you recommend and I can clean it up, unless you would rather do it yourself.

Thanks :+1:

Jieiku commented 4 years ago

I have asked at the project, if it is possible to overwrite existing files: https://github.com/kangax/html-minifier/issues/1062

alanorth commented 4 years ago

HTML (and CSS) are gzipped by the web server transparently, making minimization unnecessary. See attached screenshot from my blog:

Screenshot from 2020-01-27 10-25-17-fs8

Jieiku commented 4 years ago

Yes, you are right, I just really like clean looking source code. I guess you could say I am a bit OCD.

Edit: this post reminded me what I need to work on next, always something to work on.

alanorth commented 4 years ago

I guess this belongs in your theme itself as some sort of post-Hugo processing step then. Or in a git pre-commit hook (if your blog is in git). :P