Hello.
My website https://www.stenografia.pl had migrated to hugo and I learned a lot, thanks. Now I port my old blog posts to the new site. For now there are slightly below 200 posts, but there are going to be more.
The content dir is 178MB
The webpage renders in more than 30 seconds.
But only for the first time (no matter if I call server or not) after I remove all from public dir.
I know, it may be the HDD.
But on the laptop with new SDD (and pretty new CPU and lots of RAM) it also takes some time.
My question is: Is it right? Should I change something in configuration or not?
Below some parametres:
Start building sites …
hugo v0.84.4-020E4ACE windows/amd64 BuildDate=2021-07-01T11:51:55Z VendorInfo=gohugoio
| PL
-------------------+------
Pages | 282
Paginator pages | 37
Non-page files | 838
Static files | 33
Processed images | 0
Aliases | 35
Sitemaps | 1
Cleaned | 0
Built in 31232 ms
>hugo env
hugo v0.84.4-020E4ACE windows/amd64 BuildDate=2021-07-01T11:51:55Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.16.5"
system: Windows 7
CPU: Intel Core i7 870@2.93Ghz
RAM: 16GB
(comp rather old but still gold ;))
I deleted the contents of public dir and then gave the command. Here you are:
steno2>hugo --templateMetrics --templateMetricsHints
Start building sites …
hugo v0.84.4-020E4ACE windows/amd64 BuildDate=2021-07-01T11:51:55Z VendorInfo=gohugoio
Template Metrics:
cache cumulative average maximum
potential duration duration duration count template
----- ---------- -------- -------- ----- --------
0 1.6800962s 8.984471ms 128.0074ms 187 blog/single.html
67 1.0360592s 3.536038ms 120.0069ms 293 partials/sidebar-content.html
0 295.0167ms 6.413406ms 131.0075ms 46 _default/list.html
0 257.0149ms 8.031715ms 55.0032ms 32 _default/single.html
21 152.009ms 3.234234ms 129.0074ms 47 partials/inline/pagination/default
72 118.0069ms 402.753µs 30.0017ms 293 partials/header.html
0 107.0064ms 3.057325ms 38.0022ms 35 _internal/_default/rss.xml
0 96.0056ms 6.400373ms 17.0009ms 15 index.html
0 96.0055ms 96.0055ms 96.0055ms 1 index.json
0 58.0034ms 4.4618ms 9.0005ms 13 blog/list.html
0 39.0019ms 159.191µs 1.0001ms 245 _internal/shortcodes/figure.html
100 36.0014ms 122.871µs 1.0001ms 293 partials/footer.html
0 14.0008ms 14.0008ms 14.0008ms 1 _internal/_default/sitemap.xml
0 7.0003ms 200.008µs 1.0001ms 35 _internal/shortcodes/youtube.html
0 4.0003ms 114.294µs 1.0001ms 35 _internal/alias.html
0 0s 0s 0s 1 shortcodes/search.html
0 0s 0s 0s 1 404.html
| PL
-------------------+------
Pages | 291
Paginator pages | 39
Non-page files | 854
Static files | 33
Processed images | 0
Aliases | 35
Sitemaps | 1
Cleaned | 0
Total in 34063 ms
I don’t have the public repo of this website.
Now please post the content of layouts/partials/sidebar-content.html
as this is the most time eating partial. Also the place where the partial is called. It looks like you could cache it 2 out of three cases.
Well, when I give “hugo” command for the first time, it eats time. But next time the compilation goes in second or two.
themes\strange-case-steno\layouts\partials\sidebar-content.html:
<div class="sidebar-content">
<a href="{{ .Site.BaseURL }}"><h1>{{ .Site.Title }}</h1></a>
<p>{{ .Site.Params.description }}</p>
<!-- second description "sidebarFreeText" in config.toml -->
{{ if .Site.Params.sidebarFreeText }}
<div class="sidebar-freetext">
<p>{{ .Site.Params.sidebarFreeText }}</p>
</div>
{{ end }}
<!-- menu "icons" (menu.icons in config.toml) -->
<ul class="sidebar-menus sidebar-icons">
{{ range .Site.Menus.icons }}
<li><a href="{{.URL}}">{{ .Post }}</a></li>
{{end}}
</ul>
<!-- menu main (menu.main in config.toml) -->
<ul class="sidebar-menus">
{{ range .Site.Menus.main }}
<!-- <li>» <a href="{{.URL}}">{{ .Name }}</a>{{ .Post }}</li> -->
<li>{{ .Post }} <a href="{{.URL}}">{{ .Name }}</a></li>
{{end}}
</ul>
<!-- recent posts from certain directory (at here it's "blog") -->
<div class="sidebar-recent hidden-xs">
<p>Randomowe wpisy blogowe:</p>
<ul>
{{ range shuffle (where .Site.RegularPages "Section" "blog") | first 3 }}
<li>» <a href="{{.Permalink}}">{{ .Title }}</a></li>
{{ end }}
</ul>
</div>
{{ if .Site.Params.contact_email }}
<div class="sidebar-contact">
» <a href="mailto:{{ .Site.Params.contact_email }}">Napisz mejla</a>
</div>
{{ end }}
<!--
<p class="copyright">{{ with .Site.Params.copyright }}{{ . }}{{ else }}© {{ now.Format "2006" }}. All rights reserved. {{end}}</p>
-->
<p class="copyright">{{ with .Site.Params.copyright }}{{ . }}{{ else }}© {{ now.Format "2006" }}
<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Stenografia.pl</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://stenografia.pl" property="cc:attributionName" rel="cc:attributionURL">Krzysztof Smirnow</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Licencja Creative Commons" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png" /> International</a>. {{end}}</p>
<p class="attr">Powered by <a href="http://gohugo.io">Hugo</a> & <a href="https://github.com/ExchangeRate-API/strange-case">Strange Case</a> (inspired by <a href="https://github.com/poole/hyde">Hyde</a> and <a href="https://www.glyphicons.com/">Glyphicons</a>).</p>
</div>
Well, when I give “hugo” command for the first time, it eats time. But next time the compilation goes in second or two.
In that case it might be the compilation of your stylesheets? Do you use SCSS and pipelines?
I think, I don’t. Although I use the ready-to-use template Strange Case slightly modified by me. In fact I didn’t dig in, as it works.
I noticed significant increase of compilation time as I began to recover my old blog posts into webpage content. But lately, when it become even 30 seconds, I was a little confused.
That’s why I decided to ask.
Without access to your project, all I can do is guess, which is wasteful of both your time and mine.
However, for comparison purposes, I have a local test project with 584 MB of images in the content directory. When I do this:
rm -rf resources/ public/ && hugo
the total build time is less than 1 second.
Directory static is 29MB
Thanks, I will.
I notice in your template you’re using some HTML commenting. I think you’re doing this to remove bits of code you don’t want to run.
Please read the hugo docs about commenting, as HTML comments don’t work the way you might expect in templates.
(I’ve no idea whether this will speed things up, but regardless it’s worth fixing.)
Thanks for the advice. I think I just cleared up this mistake. Tomorrow I will check on the computer stated in my first post, how’s rendering time, but today on much faster machine it looks promising.