Hey
What do you use to delete empty lines? Gulp? Webpack? Other tool?
Hey
What do you use to delete empty lines? Gulp? Webpack? Other tool?
You mean in the html output?
You should be able to control most whitespace with the template.
See whitespace section:
Yes, html output but I noticed when I have some comments in code I have empty lines.
I would like to get rid of them, during development it would be easier read for example meta tags etc
You should just need to add a dash in the right places to control the whitespace.
Do you have an example of the part of the template producing unwanted whitespace?
<head>
<!-- {{- if not (eq $.Site.Language.LanguageName "Spanish") }}
<meta name=”robots” content=”noindex”>
{{- end }} -->
<link rel="preconnect" href="https://www.googletagmanager.com">
<!-- <title>Something like this</title> -->
<!-- <title>Something like this and test other title </title> -->
<!-- <title>Something like this and test another title</title> -->
<!-- <title>Something like this</title> -->
<!-- <title>Something like this</title> -->
<!-- <title>Something like this</title> -->
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-touch-icon.png">
give:
<!DOCTYPE HTML>
<html lang="en">
<head>
<link rel="preconnect" href="https://www.googletagmanager.com">
<link rel="apple-touch-icon" sizes="180x180" href="/images/favicon/apple-touch-icon.png">
As you see, there are 6 empty lines becouse of commented code
Put them in a comment block surrounded by {{/* */}}
Hugo/GO comments use {{/* */}}
or you can nest the comments together like so
{{- /*
<!-- <title>Something like this</title> -->
<!-- <title>Something like this and test other title </title> -->
<!-- <title>Something like this and test another title</title> -->
<!-- <title>Something like this</title> -->
<!-- <title>Something like this</title> -->
<!-- <title>Something like this</title> -->
*/ -}}
Thank you @andrewd72 and @Arif I don’t know that. Do you know some extension for VSC to add comments like this?
Also,
Still looking for better way to delete empty lines, a have a lot of indentations for better readibility in my code and at output is alsoo in bad hierarchy. Something automation like this would be great Free Online HTML Formatter - FreeFormatter.com
I wouldn’t spend a lot of time on this:
This is a portion of Apple’s home page, displayed using the browser’s “view source” option, typically Ctrl+U
.
View the same page using the browser’s dev tools, typically Ctrl+Shift+I
.
And if you minify your HTML for production (hugo --minify
) the redundant white space is removed.