When I run server with Template Metrics, it shows that it hits the internal alias template 7 times, but I have only 6 content pages, including the home page, and none of them have an alias in their frontmatter. I do have permalinks in the config file. Could that be causing it? So it is making a page in the original location and then making a page in the specified permalink location? Update: it’s not the permalink stuff because I turn it off and it still hits the alias.
[permalinks]
page = "/:slug/"
blog = "/:slug/"
posts = "/:slug/"
hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended windows/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio
INFO 2022/08/30 21:46:07 syncing static files to \
Template Metrics:
cumulative average maximum cache percent cached total
duration duration duration potential cached count count template
---------- -------- -------- --------- ------- ------ ----- --------
5.3949626s 359.664173ms 696.6696ms 100 0 0 15 partials/style.html
1.3971526s 698.5763ms 698.5775ms 0 0 0 2 _default/single.html
761.1246ms 126.8541ms 715.5623ms 0 0 0 6 _default/list.html
729.3245ms 729.3245ms 729.3245ms 0 0 0 1 index.html
708.3407ms 708.3407ms 708.3407ms 0 0 0 1 _default/contact.html
691.3516ms 691.3516ms 691.3516ms 0 0 0 1 _default/search.html
682.5925ms 341.29625ms 680.498ms 0 0 0 2 _default/terms.html
681.5863ms 681.5863ms 681.5863ms 0 0 0 1 _default/about.html
77.0868ms 7.00789ms 29.867ms 0 0 0 11 _default/large-card.html
58.7061ms 3.91374ms 35.1101ms 29 0 0 15 partials/head.html
29.3503ms 9.783433ms 11.8505ms 0 0 0 3 shortcodes/figure.html
19.3299ms 1.28866ms 3.466ms 99 0 0 15 partials/header.html
13.6204ms 454.013µs 2.7477ms 100 47 14 30 partials/logo.html
9.8643ms 657.62µs 4.9881ms 98 0 0 15 partials/footer.html
6.2398ms 3.1199ms 3.6158ms 0 0 0 2 _default/_markup/render-image.html
5.2564ms 5.2564ms 5.2564ms 100 0 0 1 partials/widgets/recent-post.html
5.2564ms 5.2564ms 5.2564ms 0 0 0 1 partials/widgets/widget-wrapper.html
4.995ms 555µs 999µs 0 0 0 9 _internal/_default/rss.xml
2.3272ms 110.819µs 528.7µs 100 0 0 21 partials/functions/get-image.html
1.5355ms 1.5355ms 1.5355ms 0 0 0 1 _default/index.webmanifest
1.0001ms 1.0001ms 1.0001ms 0 0 0 1 404.html
999.3µs 999.3µs 999.3µs 0 0 0 1 _internal/_default/sitemap.xml
502.8µs 33.52µs 502.8µs 100 0 0 15 partials/script.html
0s 0s 0s 100 100 8 8 partials/widgets/widget-wrapper
0s 0s 0s 0 0 0 1 scss/style.scss
0s 0s 0s 0 0 0 7 _internal/alias.html
0s 0s 0s 0 0 0 1 _default/_markup/render-link.html
| EN
-------------------+-----
Pages | 25
Paginator pages | 0
Non-page files | 8
Static files | 35
Processed images | 69
Aliases | 7
Sitemaps | 1
Cleaned | 0
Also, how do I navigate to the rss.xml or index.webmanifest in server mode? I go there and it says not found. The sitemap.xml works though.
idarek
August 31, 2022, 6:35am
2
Aliases
I may be wrong, but into Aliases there are counted other URL as well, not only this specified in frontmatter as an aliases
. I got website with just one aliases
specified but more in stats.
Pages | 1019
Paginator pages | 5
Non-page files | 232
Static files | 32
Processed images | 928
Aliases | 477
Sitemaps | 1
Cleaned | 0
how do I navigate to the rss.xml or index.webmanifest in server mode?
Could you provide link to your depot.
tut
August 31, 2022, 9:11am
3
If you use pagination, its links are generated as aliases. Disable pagination and do a comparison of the results.
I commented out the pagination stuff in the layout templates but it still creates 7 aliases. Unless there is a different way to turn off pagination.
What does this mean? Please show an example of how you “commented out.”
And do this to find the aliases created:
hugo
grep -r 'http-equiv="refresh"' public/
1 Like
Basically in the index.html I commented out this bit:
<!-- custom pagination -->
{{ $paginator := $.Paginator }}
<!-- Number of links either side of the current page. -->
{{ $adjacent_links := 2 }}
<!-- $max_links = ($adjacent_links * 2) + 1 -->
{{ $max_links := (add (mul $adjacent_links 2) 1) }}
<!-- $lower_limit = $adjacent_links + 1 -->
{{ $lower_limit := (add $adjacent_links 1) }}
<!-- $upper_limit = $paginator.TotalPages - $adjacent_links -->
{{ $upper_limit := (sub $paginator.TotalPages $adjacent_links) }}
<!-- If there's more than one page. -->
{{ if gt $paginator.TotalPages 1 }}
<nav aria-label="Pagination Navigation">
<ul class="pagination align-items-center justify-content-center">
<!-- Previous page. -->
{{ if $paginator.HasPrev }}
<li class="page-item prev d-flex align-items-center">
<a class="page-link disabled" href="{{ printf "%s#%s" $paginator.Prev.URL (site.Params.recentPostTitle | urlize) }}" aria-label="Pagination"><i class="fas fa-arrow-left me-3"></i><span class="d-none d-sm-inline">Previous</span>
</a>
</li>
{{ else }}
<li class="page-item prev d-flex align-items-center disabled">
<span class="page-link disabled"><i class="fas fa-arrow-left me-3"></i><span class="d-none d-sm-inline">Previous</span>
</span>
</li>
{{ end }}
<!-- Page numbers. -->
{{ range $paginator.Pagers }}
{{ $.Scratch.Set "page_number_flag" false }}
<!-- Advanced page numbers. -->
{{ if gt $paginator.TotalPages $max_links }}
<!-- Lower limit pages. -->
<!-- If the user is on a page which is in the lower limit. -->
{{ if le $paginator.PageNumber $lower_limit }}
<!-- If the current loop page is less than max_links. -->
{{ if le .PageNumber $max_links }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Upper limit pages. -->
<!-- If the user is on a page which is in the upper limit. -->
{{ else if ge $paginator.PageNumber $upper_limit }}
<!-- If the current loop page is greater than total pages minus $max_links -->
{{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Middle pages. -->
{{ else }}
{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add $paginator.PageNumber $adjacent_links) ) }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
{{ end }}
<!-- Simple page numbers. -->
{{ else }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}
<!-- Output page numbers. -->
{{ if eq ($.Scratch.Get "page_number_flag") true }}
<li class="page-item">
{{ if eq . $paginator }}
<span class="page-link active">{{ .PageNumber }}</span>
{{ else }}
<a href="{{ printf "%s#%s" .URL (site.Params.recentPostTitle | urlize) }}" class="page-link" aria-label="Page">{{ .PageNumber }}</a>
{{ end }}
</li>
{{ end }}
{{ end }}
<!-- Next page. -->
{{ if $paginator.HasNext }}
<li class="page-item next d-flex align-items-center">
<a class="page-link arrow" href="{{ printf "%s#%s" $paginator.Next.URL (site.Params.recentPostTitle | urlize) }}" aria-label="Pagination"><span class="d-none d-sm-inline">Next</span><i class="fas fa-arrow-right ms-3"></i>
</a>
</li>
{{ else }}
<li class="page-item next d-flex align-items-center disabled">
<span class="page-link arrow"><span class="d-none d-sm-inline">Next</span><i class="fas fa-arrow-right ms-3"></i>
</span>
</li>
{{ end }}
</ul>
</nav>
{{ end }}
{{ end }}
And again in the list.html
i had to do grep -r 'http-equiv=refresh' public/
because with the double quotes around refresh didn’t find anything.
I got:
public/blog/page/1/index.html:<!doctype html><html lang=en-us><head><title>https://www.example.com/blog/</title><link rel=canonical href=https://www.example.com/blog/><meta name=robots content="noindex"><meta charset=utf-8><meta http-equiv=refresh content="0; url=https://www.example.com/blog/"></head></html>
public/categories/american/page/1/index.html:<!doctype html><html lang=en-us><head><title>https://www.example.com/categories/american/</title><link rel=canonical href=https://www.example.com/categories/american/><meta name=robots content="noindex"><meta charset=utf-8><meta http-equiv=refresh content="0; url=https://www.example.com/categories/american/"></head></html>
public/page/1/index.html:<!doctype html><html lang=en-us><head><title>https://www.example.com/</title><link rel=canonical href=https://www.example.com/><meta name=robots content="noindex"><meta charset=utf-8><meta http-equiv=refresh content="0; url=https://www.example.com/"></head></html>
public/tags/savory/page/1/index.html:<!doctype html><html lang=en-us><head><title>https://www.example.com/tags/savory/</title><link rel=canonical href=https://www.example.com/tags/savory/><meta name=robots content="noindex"><meta charset=utf-8><meta http-equiv=refresh content="0; url=https://www.example.com/tags/savory/"></head></html>
public/tags/sweet/page/1/index.html:<!doctype html><html lang=en-us><head><title>https://www.example.com/tags/sweet/</title><link rel=canonical href=https://www.example.com/tags/sweet/><meta name=robots content="noindex"><meta charset=utf-8><meta http-equiv=refresh content="0; url=https://www.example.com/tags/sweet/"></head></html>
That’s 5 aliases generated, each resulting from pagination.
yea, well it explains it and it makes sense. Thanks for the insight into “debugging” that with grep.
And when you “comment out” code, make sure you do this:
{{/*
{{ add 1 1 }}
*/}}
Not this:
<!--
{{ add 1 1 }}
-->
Yep. I have the hugo plugin that comments out template code that way by default.
system
Closed
September 4, 2022, 12:14pm
14
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.