I would like to make a list of all the .html files in use by Hugo from the /layouts/ directory. I can’t think of anything. Is it possible to output the list of said files while building Hugo or in a test template somewhere?
I’d prefer a usable list, in some kind of array notation. I need to use this in my postcss.config for UnCSS.
Currently I am globbing /layouts/**/*.html
but this takes upwards of 45 seconds to build sometimes.
Instead, I’d like to create a list of files used by Hugo, grab that list somehow, and feed that into my postcss config.
Ideas? Opinions? I don’t want to hard code the list of files as that is likely to change around. I was hoping to automate as much of that as possible.
Here’s the related thread.
So far I’ve tried the following:
hugo --logFile hugo.log --debug -v
Not seeing much in console output either.
I get something back by using Template Metrics. That’s nice. It’s a list of templates files used, but it also spits out files that are currently not actively in use (as far as I know they should not be in use).
Template Metrics:
cumulative average maximum
duration duration duration count template
---------- -------- -------- ----- --------
3.046760862s 40.088958ms 697.755868ms 76 partials/head.html
2.906716588s 581.343317ms 722.912977ms 5 page/single.html
1.098503038s 31.385801ms 60.895054ms 35 _default/list.html
839.253243ms 33.570129ms 47.620119ms 25 _default/single.html
629.871959ms 8.511783ms 27.043797ms 74 partials/sidebar.html
553.828881ms 12.307308ms 36.301951ms 45 partials/carousel_featured.html
494.899572ms 292.839µs 17.346736ms 1690 partials/share.html
311.362407ms 34.595823ms 63.571616ms 9 section/psychedelics.html
173.805565ms 2.286915ms 12.586046ms 76 partials/footer.html
169.339522ms 2.288371ms 21.913328ms 74 partials/widgets/tags.html
161.453369ms 6.458134ms 15.398798ms 25 partials/carousel_section.html
151.425523ms 2.04629ms 12.925347ms 74 partials/widgets/related.html
147.184711ms 1.962462ms 19.653443ms 75 partials/scripts.html
96.166771ms 1.282223ms 11.474135ms 75 partials/seo/schema.html
75.946162ms 999.291µs 12.871704ms 76 partials/nav.html
71.757458ms 969.695µs 14.859757ms 74 partials/widgets/authors.html
59.795427ms 808.046µs 2.061811ms 74 partials/widgets/featured.html
56.359822ms 761.619µs 1.468804ms 74 partials/widgets/recent.html
55.227005ms 2.20908ms 5.716819ms 25 partials/related.html
51.637516ms 697.804µs 2.128365ms 74 partials/widgets/categories.html
36.57592ms 36.57592ms 36.57592ms 1 index.html
34.500248ms 766.672µs 3.28561ms 45 _internal/_default/rss.xml
18.869163ms 786.215µs 2.846969ms 24 shortcodes/related.html
18.679131ms 122.085µs 3.732141ms 153 partials/site_social.html
17.323147ms 251.06µs 1.64253ms 69 partials/author.html
12.416693ms 12.416693ms 12.416693ms 1 partials/contact.html
12.030219ms 158.292µs 861.036µs 76 partials/seo/twitter.html
11.908406ms 160.924µs 3.575392ms 74 partials/widgets/search.html
11.78568ms 346.637µs 4.220446ms 34 shortcodes/imgcap.html
11.033232ms 143.288µs 2.148464ms 77 partials/signup_bottom.html
8.757772ms 437.888µs 902.047µs 20 shortcodes/blockquote.html
7.534573ms 101.818µs 391.466µs 74 partials/breadcrumbs.html
6.239547ms 6.239547ms 6.239547ms 1 partials/recent_psychedelics.html
5.654745ms 76.415µs 2.678919ms 74 partials/widgets/facebook.html
4.5269ms 43.527µs 323.29µs 104 _internal/alias.html
4.16223ms 166.489µs 1.729656ms 25 shortcodes/signup.html
4.0213ms 4.0213ms 4.0213ms 1 partials/testimonials.html
3.900172ms 3.900172ms 3.900172ms 1 partials/recent_blog.html
3.493213ms 3.493213ms 3.493213ms 1 404.html
3.462946ms 3.462946ms 3.462946ms 1 _internal/_default/sitemap.xml
2.634391ms 35.599µs 153.951µs 74 partials/widgets/signup.html
2.446777ms 33.064µs 1.142847ms 74 partials/widgets/phplist.html
1.710543ms 1.710543ms 1.710543ms 1 partials/drugs.html
1.692676ms 65.102µs 483.096µs 26 partials/signup.html
1.465233ms 19.8µs 218.185µs 74 partials/widgets/maps_news.html
919.076µs 919.076µs 919.076µs 1 partials/recent_news.html
801.174µs 801.174µs 801.174µs 1 partials/map.html
685.037µs 13.173µs 607.68µs 52 partials/mailchimp.html
658.283µs 658.283µs 658.283µs 1 partials/top.html
645.086µs 645.086µs 645.086µs 1 shortcodes/aboutimg.html
629.664µs 629.664µs 629.664µs 1 partials/team.html
599.953µs 599.953µs 599.953µs 1 _internal/shortcodes/youtube.html
518.785µs 259.392µs 491.038µs 2 partials/hero.html
510.591µs 510.591µs 510.591µs 1 partials/see_more.html
504.808µs 504.808µs 504.808µs 1 partials/pp.html
451.187µs 112.796µs 272.348µs 4 shortcodes/radio.html
425.982µs 425.982µs 425.982µs 1 partials/clients.html
424.215µs 424.215µs 424.215µs 1 shortcodes/calc.html
326.994µs 326.994µs 326.994µs 1 partials/pc.html
313.152µs 313.152µs 313.152µs 1 partials/welcome.html
1.534µs 1.534µs 1.534µs 1 robots.txt
Lot of the files shown here are not in use. I wonder why it even shows them.;
$ hugo --templateMetrics --templateMetricsHints | awk '{ print $6 }' | grep html | sort
404.html
_default/list.html
_default/single.html
index.html
_internal/alias.html
_internal/shortcodes/youtube.html
page/single.html
partials/author.html
partials/breadcrumbs.html
partials/carousel_featured.html
partials/carousel_section.html
partials/clients.html
partials/contact.html
partials/drugs.html
partials/footer.html
partials/head.html
partials/hero.html
partials/mailchimp.html
partials/map.html
partials/nav.html
partials/pc.html
partials/pp.html
partials/recent_blog.html
partials/recent_news.html
partials/recent_psychedelics.html
partials/related.html
partials/scripts.html
partials/see_more.html
partials/seo/schema.html
partials/seo/twitter.html
partials/share.html
partials/sidebar.html
partials/signup_bottom.html
partials/signup.html
partials/site_social.html
partials/team.html
partials/testimonials.html
partials/top.html
partials/welcome.html
partials/widgets/authors.html
partials/widgets/categories.html
partials/widgets/facebook.html
partials/widgets/featured.html
partials/widgets/maps_news.html
partials/widgets/phplist.html
partials/widgets/recent.html
partials/widgets/related.html
partials/widgets/search.html
partials/widgets/signup.html
partials/widgets/tags.html
section/psychedelics.html
shortcodes/aboutimg.html
shortcodes/blockquote.html
shortcodes/calc.html
shortcodes/imgcap.html
shortcodes/radio.html
shortcodes/related.html
shortcodes/signup.html
I mean, I’m closer to where I want to be, but I still need to know why files which are not in use are still showing up in this list. For example, none of the widget files are in use, but they still show up.
I have other shortcodes for example that are not in use, and they don’t show up.
I’d be very grateful if anyone can shed light on this. Obviously, going this silly route to get the list of files is probably not optimal.