Skip to main content
  1. 2022/
  2. July/

Hugo Spelunking

·2 mins

https://gohugo.io/functions/format/### String Padding

Found this on the [Go Samples][gosamples-site] Site:

Using the built-in fmt.Printf() function, you can set the format of the printed data using so-called verbs such as "%s". Moreover, there are several flags to improve the display of strings. One of them is the flag to add padding, which is the number specifying its size in the verb "%s", between "%" and "s". By default, the string is padded with spaces on the left (the text is right-justified). If you want right padding and left alignment, add the - flag before the padding size.

Examples: #
format description
"%s" Standard string format
"%20s" Pad string with the spaces on the left (right-justified string)
"%-20s" Pad string with the spaces on the right (left-justified string)
Left padding example #
// left padding
fmt.Printf("+%s+\n", strings.Repeat("-", 45))
fmt.Printf("| %20s | %20s |\n", "vegetables", "fruits")
fmt.Printf("|%s|\n", strings.Repeat("-", 45))
fmt.Printf("| %20s | %20s |\n", "potato", "strawberry")
fmt.Printf("+%s+\n", strings.Repeat("-", 45))
Output #
+---------------------------------------------+
|           vegetables |               fruits |
|---------------------------------------------|
|               potato |           strawberry |
+---------------------------------------------+

I found this on the [hugo discourse site][hugo-discourse-multiple-permalinks]

“Using 2 links (just as a links) to that same article is bad for SEO. Google and others will penalize you for Duplicated Content. To do this correctly, one link shall be set as canonical. The best is to do a 301 redirects but you can also use the Hugo aliases feature.

---
url: 
aliases:
---

— back to your question —

Re to ‘/:year/:month/:day’ just create a folder structure in YYYY/MM/DD and that’s will be sorted by default unless url specified. Then do alias manually or specify archetype for that do this automatically based on filename if you will be using hugo new to add post.

For example this:

title: "{{ replace .Name "-" " " | title }}" Will create title automatically prefilled based on markdown filename (that may be your slug) Next, just sort the year and date automatic generation.

for example:

aliases: /{{ dateFormat "2006" .Date }}/{{ dateFormat "01" .Date }}/{{ replace .Name "-" " " | title }} The aliases however are meta redirects hence you will not be using them for positioning in search engines and the only 1 URL shall be. [hugo-discourse-multiple-permalinks]: https://discourse.gohugo.io/t/multiple-permalinks/38992/2 [gosamples-site]: https://gosamples.dev/string-padding/

https://discourse.gohugo.io/t/range-sort-by-frontmatter/39527

https://gohugo.io/content-management/related/

https://discourse.gohugo.io/t/range-sort-by-frontmatter/39527
There is a ByParam method on the page colleciton.

https://gohugo.io/getting-started/configuration/

https://kinsta.com/blog/hugo-static-site/

https://pagespeed.web.dev

https://gohugo.io/hosting-and-deployment/hugo-deploy/

https://martijnvanvreeden.nl/portfolio/ https://martijnvanvreeden.nl/10-ways-to-improve-your-hugo-website-performance/

https://blog.callr.tech/static-website-performance-seo/ https://blog.callr.tech/static-web-roots/ https://blog.callr.tech/static-blog-hugo-docker-gitlab/ https://www.ernestchiang.com/en/posts/2021/my-hugo-workflow/

https://discourse.gohugo.io/t/splitting-an-article-into-multiple-pages/29161