Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTML tidying as an option #7190

Open
asomervell opened this issue Apr 20, 2020 · 10 comments · Fixed by grahamsz/hugo#1 · May be fixed by #7825
Open

Add HTML tidying as an option #7190

asomervell opened this issue Apr 20, 2020 · 10 comments · Fixed by grahamsz/hugo#1 · May be fixed by #7825
Milestone

Comments

@asomervell
Copy link

https://gohugo.io/news/0.69.0-relnotes/

Given the hugo templating engine creates whitespace hell in output now that resources.PostProcess exists it would be awesome to have a similar hook to tidy the output HTML.

Here's a great Go lib that does it perfectly https://github.com/yosssi/gohtml

@bep
Copy link
Member

bep commented Apr 20, 2020

You know you can minify the output?

@asomervell
Copy link
Author

Yes. Not really the point though when you're design focused and looking at your DOM output. I know the javascript world has destroyed that but one of the nicest things about hugo is outputting simple, classic static html.

Thanks for all the work you do on hugo 🙏🏽

@bep bep changed the title With the release of 0.69... Hugo post process should allow HTML tidying Add HTML tidying as an option Apr 20, 2020
@bep bep added Enhancement and removed Proposal labels Apr 20, 2020
@bep
Copy link
Member

bep commented Apr 20, 2020

You're right, the HTML output from Go templates leave much to be desired ...

Note that I think this should be implemented in the same place as we do output minification. PostProcess is something ... different (not sure what ... yet).

@bep bep added this to the v0.70 milestone Apr 20, 2020
@bep bep modified the milestones: v0.70, v0.71 Apr 28, 2020
@bep bep modified the milestones: v0.71, v0.72 May 18, 2020
@bep bep modified the milestones: v0.72, v0.73 May 31, 2020
@bep bep modified the milestones: v0.73, v0.74 Jun 23, 2020
@bep bep modified the milestones: v0.74, v0.75 Jul 13, 2020
@bep bep modified the milestones: v0.75, v0.76 Sep 14, 2020
@bep bep modified the milestones: v0.76, v0.77 Oct 6, 2020
fvbommel added a commit to fvbommel/hugo that referenced this issue Oct 13, 2020
This is similar to --minify, but has essentially the opposite effect:
instead of making the output less readable it makes it *more* readable.

This uses github.com/yosssi/gohtml to perform the actual transformation.

Fixes gohugoio#7190
fvbommel added a commit to fvbommel/hugo that referenced this issue Oct 13, 2020
This is similar to --minify, but has essentially the opposite effect:
instead of making the output less readable it makes it *more* readable.

This uses github.com/yosssi/gohtml to perform the actual transformation.

Fixes gohugoio#7190
@fvbommel fvbommel linked a pull request Oct 13, 2020 that will close this issue
5 tasks
@fvbommel
Copy link

I've written an initial implementation of this: #7825

I'd love some feedback.

@bep bep modified the milestones: v0.77, v0.78 Oct 30, 2020
@bep bep modified the milestones: v0.78, v0.83 Apr 23, 2021
@bep bep added this to the v0.111.0 milestone Jan 26, 2023
@bep bep modified the milestones: v0.111.0, v0.112.0 Feb 15, 2023
@bep bep modified the milestones: v0.112.0, v0.113.0 Apr 15, 2023
@bep bep modified the milestones: v0.113.0, v0.115.0 Jun 13, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@williamhaley
Copy link

williamhaley commented Mar 16, 2024

As an inelegant workaround I do something like the following. I like having predictable and clean HTML output for a particular hugo project I'm working on.

# build.sh

hugo

npx prettier@3.2.5 "public/**/*.html" --parser html --write
npx prettier@3.2.5 "public/**/*.json" --parser json --write

@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants