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

Hugo Spelunking

·2 mins 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.


— 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]: [gosamples-site]:
There is a ByParam method on the page colleciton.