SEO With Hugo (11) Minifying Html
by Samuele Lilliu | 29 January 2023
Minifying HTML removes unnecessary data to reduce file size, improving page load times, reducing bandwidth usage, and bettering SEO.
- Producer: Samuele Lilliu
- Software: Hugo, HTML
by Samuele Lilliu | 29 January 2023
Minifying HTML removes unnecessary data to reduce file size, improving page load times, reducing bandwidth usage, and bettering SEO.
HTML minification is the process of removing unnecessary or redundant data from an HTML file without affecting its functionality. This can include removing white space, comments, and shortening variable and function names. The goal of minification is to reduce the size of the HTML file, which can speed up page load times.
There are several benefits to minifying HTML:
To enable HTML minification in Hugo we need to add the following to config/_default/config.yaml
:
minify:
tdewolff:
html:
keepWhitespace: false
This will only minify HTML, it won’t touch CSS and JavaScript. To check if this is working you’ll have to run the Hugo server in production mode. You can double check if it is working correctly by looking at the file generated in the Hugo public folder.