Skip to content

Instantly share code, notes, and snippets.

@isotopp
Created November 24, 2020 23:14
Show Gist options
  • Save isotopp/1faafbd186666c39c9ba05602484d5d1 to your computer and use it in GitHub Desktop.
Save isotopp/1faafbd186666c39c9ba05602484d5d1 to your computer and use it in GitHub Desktop.
Trying to debug Hugo and my site
Rendering blog.koehntopp.info now takes 400s in Jekyll. That's too slow.
I can import the entire thing into hugo with `hugo import jekyll ~/Source/isotopp.github.io isotopp`
and get a hugo version of all.
That leaves me with the work to port Type-on-Strap to Hugo. But I do not
even understand how Hugo applies Templates and it is hard to debug.
kris@server:~/hugo/isotopp$ ~/Source/hugo/hugo version
Hugo Static Site Generator v0.79.0-DEV/extended linux/amd64 BuildDate: unknown
kris@server:~/Source/hugo$ git diff
diff --git a/hugolib/site.go b/hugolib/site.go
index 3d77b014..b2cd4485 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1661,7 +1661,7 @@ func (s *Site) lookupLayouts(layouts ...string) tpl.Template {
}
func (s *Site) renderAndWriteXML(statCounter *uint64, name string, targetPath string, d interface{}, templ tpl.Template) error {
- s.Log.Debug().Printf("Render XML for %q to %q", name, targetPath)
+ s.Log.Debug().Printf("Render XML (template %s) for %s to %q", templ.Name(), name, targetPath)
renderBuffer := bp.GetBuffer()
defer bp.PutBuffer(renderBuffer)
@@ -1683,7 +1683,7 @@ func (s *Site) renderAndWriteXML(statCounter *uint64, name string, targetPath st
}
func (s *Site) renderAndWritePage(statCounter *uint64, name string, targetPath string, p *pageState, templ tpl.Template) error {
- s.Log.Debug().Printf("Render %s to %q", name, targetPath)
+ s.Log.Debug().Printf("Render %s (template %s) to %q", name, templ.Name(), targetPath)
renderBuffer := bp.GetBuffer()
defer bp.PutBuffer(renderBuffer)
diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go
index e3a4ce09..abef20d1 100644
--- a/tpl/tplimpl/template.go
+++ b/tpl/tplimpl/template.go
@@ -14,6 +14,7 @@
package tplimpl
import (
+ "fmt"
"io"
"os"
"path/filepath"
@@ -224,6 +225,7 @@ func (t *templateExec) Execute(templ tpl.Template, wr io.Writer, data interface{
defer t.Metrics.MeasureSince(templ.Name(), time.Now())
}
+ fmt.Printf("Execute template %q\n", templ.Name())
execErr := t.executor.Execute(templ, wr, data)
if execErr != nil {
execErr = t.addFileContext(templ, execErr)
kris@server:~/hugo/quickstart$ ~/Source/hugo/hugo -DEF -cleanDestinationDir --debug
INFO 2020/11/25 00:07:18 Using config file:
Start building sites …
INFO 2020/11/25 00:07:18 syncing static files to /home/kris/hugo/quickstart/public/
DEBUG 2020/11/25 00:07:18 Render page Categories (template _default/terms.html) to "/categories/index.html"
Execute template "_default/terms.html"
Execute template "partials/site-favicon.html"
Execute template "partials/head-additions.html"
Execute template "partials/site-header.html"
Execute template "partials/site-navigation.html"
Execute template "partials/i18nlist.html"
Execute template "partials/social-follow.html"
Execute template "partials/site-footer.html"
Execute template "partials/social-follow.html"
DEBUG 2020/11/25 00:07:18 Render page Tags (template _default/terms.html) to "/tags/index.html"
Execute template "_default/terms.html"
Execute template "partials/site-scripts.html"
Execute template "partials/head-additions.html"
Execute template "partials/site-header.html"
Execute template "partials/site-navigation.html"
Execute template "partials/i18nlist.html"
DEBUG 2020/11/25 00:07:18 Render page Quickstart (template index.html) to "/index.html"
Execute template "index.html"
Execute template "partials/head-additions.html"
Execute template "partials/site-header.html"
Execute template "partials/site-navigation.html"
Execute template "partials/i18nlist.html"
DEBUG 2020/11/25 00:07:18 Render XML (template _internal/_default/sitemap.xml) for sitemap to "/sitemap.xml"
Execute template "_internal/_default/sitemap.xml"
DEBUG 2020/11/25 00:07:18 Render 404 page (template 404.html) to "/404.html"
Execute template "404.html"
Execute template "partials/head-additions.html"
Execute template "partials/page-header.html"
Execute template "partials/func/GetFeaturedImage.html"
Execute template "partials/site-navigation.html"
Execute template "partials/i18nlist.html"
DEBUG 2020/11/25 00:07:18 Render page Quickstart (template _internal/_default/rss.xml) to "/index.xml"
Execute template "_internal/_default/rss.xml"
DEBUG 2020/11/25 00:07:18 Render page Categories (template _internal/_default/rss.xml) to "/categories/index.xml"
Execute template "_internal/_default/rss.xml"
DEBUG 2020/11/25 00:07:18 Render page Tags (template _internal/_default/rss.xml) to "/tags/index.xml"
Execute template "_internal/_default/rss.xml"
| EN
-------------------+-----
Pages | 7
Paginator pages | 0
Non-page files | 0
Static files | 6
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 44 ms
So this leaves me with some output.
With my template
kris@server:~/hugo/isotopp$ ~/Source/hugo/hugo -DEF -cleanDestinationDir --debug
INFO 2020/11/25 00:13:48 Using config file:
Start building sites …
DEBUG 2020/11/25 00:13:48 Render page Die wunderbare Welt von Isotopp (template home.html) to "/index.html"
Execute template "home.html"
INFO 2020/11/25 00:13:48 syncing static files to /home/kris/hugo/isotopp/public/
DEBUG 2020/11/25 00:13:48 Render page Categories (template _default/list.html) to "/categories.html"
Execute template "_default/list.html"
DEBUG 2020/11/25 00:13:48 Render page Tags (template _default/list.html) to "/tags.html"
Execute template "_default/list.html"
DEBUG 2020/11/25 00:13:48 Render XML (template _internal/_default/sitemap.xml) for sitemap to "/sitemap.xml"
Execute template "_internal/_default/sitemap.xml"
DEBUG 2020/11/25 00:13:48 Render 404 page (template 404.html) to "/404.html"
Execute template "404.html"
DEBUG 2020/11/25 00:13:48 Render page Die wunderbare Welt von Isotopp (template _internal/_default/rss.xml) to "/index.xml"Execute template "_internal/_default/rss.xml"
DEBUG 2020/11/25 00:13:48 Render page Categories (template _internal/_default/rss.xml) to "/categories/index.xml"
Execute template "_internal/_default/rss.xml"
DEBUG 2020/11/25 00:13:48 Render page Tags (template _internal/_default/rss.xml) to "/tags/index.xml"
Execute template "_internal/_default/rss.xml"
| EN
-------------------+------
Pages | 6
Paginator pages | 0
Non-page files | 0
Static files | 965
Processed images | 0
Aliases | 0
Sitemaps | 1
Cleaned | 0
Total in 220 ms
Now I wonder where my baseof.html and stuff is, and if there is a way to see what
Hugo considers, but does not use and why.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment