Closed Timmy1e closed 3 months ago
hi @Timmy1e, Did you configured the minify option into config.toml?
Please refer to https://gohugo.io/getting-started/configuration/#configure-minify in order to configure it if not done already!
I used the default settings (no minify
object) and just pass the --minify
flag.
I added this and it worked.
minify:
minifyOutput: true
It is strange that it works locally without this in the config.
But it still doesn't honour the --logLevel
.
Hi @Timmy1e, Could you check if you have the docker buildx option —progress as per docker documentation: https://docs.docker.com/reference/cli/docker/buildx/build/#progress
Setting --progress=plain
doesn't fix it, this is the relevant output:
#15 [build 4/1] RUN if [ -e ".hugo-onbuild.sh" ]; then exec sh .hugo-onbuild.sh; else exec hugo $HUGO_CMD; fi
#15 0.387 Start building sites …
#15 0.387 hugo v0.124.1-db083b05f16c945fec04f745f0ca8640560cf1ec+extended linux/amd64 BuildDate=2024-03-20T11:40:10Z VendorInfo=gohugoio
#15 0.387
#15 723.3
#15 723.3 | EN | NL
#15 723.3 -------------------+----+-------
#15 723.3 Pages | 36 | 89
#15 723.3 Paginator pages | 0 | 9
#15 723.3 Non-page files | 5 | 507
#15 723.3 Static files | 0 | 0
#15 723.3 Processed images | 14 | 1480
#15 723.3 Aliases | 14 | 29
#15 723.3 Cleaned | 0 | 0
#15 723.3
#15 723.3 Total in 722955 ms
#15 DONE 725.6s
hi @Timmy1e, As per onbuild image documented here - https://github.com/floryn90/docker-hugo#using-onbuild-image - the HUGO_CMD should be passed to the docker build as argument and not as env variable!
eg:
docker build --progress plain --build-arg HUGO_CMD="--enableGitInfo --minify --logLevel info" --build-arg HUGO_ENV_ARG="production" .
Example using your Dockerfile where I removed only
ENV HUGO_CMD="--enableGitInfo --minify --logLevel info"
ENV HUGO_ENV_ARG="production"
Which will produce the following output:
#12 0.402 Start building sites …
#12 0.402 hugo v0.124.1-db083b05f16c945fec04f745f0ca8640560cf1ec+extended linux/amd64 BuildDate=2024-03-20T11:40:10Z VendorInfo=gohugoio
#12 0.402
#12 0.415 INFO build: step process substep collect files 0 files_total 0 duration 34.2µs
#12 0.415 INFO build: step process duration 212.4µs
#12 0.415 INFO build: step assemble duration 583.299µs
#12 0.437 INFO Data for key 'showcase' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.437 INFO Data for key 'about' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.437 INFO Data for key 'education' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.437 INFO Data for key 'experience' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.437 INFO Data for key 'client_and_work' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.437 INFO Data for key 'testimonial' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.437 INFO Data for key 'contact' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.437 INFO Data for key 'newsletter' in path 'homepage.yml' is overridden by higher precedence data already in the data tree
#12 0.447 INFO build: step render substep pages site en outputFormat html duration 30.986976ms
#12 0.447 INFO deprecated: .Site.Author was deprecated in Hugo v0.124.0 and will be removed in a future release. Use taxonomies instead.
#12 0.448 INFO build: step render substep pages site en outputFormat rss duration 1.925598ms
#12 0.448 INFO build: step render pages 5 content 0 duration 33.130874ms
#12 0.449 INFO build: step postProcess duration 750.299µs
#12 0.449 INFO build: duration 35.505772ms
#12 0.490 INFO static: syncing static files to / duration 75.95804ms
#12 0.490
#12 0.490 | EN
#12 0.490 -------------------+------
#12 0.490 Pages | 5
#12 0.490 Paginator pages | 0
#12 0.490 Non-page files | 0
#12 0.490 Static files | 150
#12 0.490 Processed images | 0
#12 0.490 Aliases | 0
#12 0.490 Cleaned | 0
#12 0.490
#12 0.490 Total in 91 ms
#12 DONE 0.5s
Hi, I created an issue in the past about the
--enableGitInfo
flag which was an issue on my end. But when I pass--minify
or set a log level using--logLevel info
using the onbuild image it doesn't work. My project doesn't contain a.hugo-onbuild.sh
file, and I use the following Dockerfile:With the relevant log section:
But when I locally run Hugo with the same parameters it does minify and print info level messages.
Which results in the following logs:
The local
index.html
is 4.0kB and minified. The onbuildindex.html
is 12kB and has a lot of empty lines.I have the result of the listed Dockerfile running on a public server, where you can see that the HTML is not being minified.