Hugo: List tags with link and comma separated?

hugo functions
hugo delimit
hugo if else
hugo range $index
hugo variables
hugo documentation
hugo join list

I'm using Hugo to make a website, and I want to show a clickable comma separated list of all the tags of a page.

I can simply show all tags like this:

Tags: {{ delimit .Params.tags ", " }}

However, then the tags aren't clickable. I can make them clickable by using range:

Tags:
{{ range .Params.tags }}
<a href='{{ "/tags/" | relLangURL }}{{ . | urlize }}'>{{ . | humanize }}</a>,
{{ end }}

But then I have a trailing comma that's not supposed to be there.

I had this fix where I wrap the comma in a css class unlessLast and then hide it using css:

.unlessLast:last-child {
    display: none;
}

But I was wondering if there is a nice way of not even generating the trailing comma with Hugo.

So, how do I remove this comma properly?

I figured something out, where instead of a trailing , I add one in front of each element, but hide the first one. Checking if an element is the first one is easy:

{{ range $i, $e := .Params.tags -}}
    {{- if $i -}}, {{ end -}}
    <a href='{{ "/tags/" | relLangURL }}{{ . | urlize }}'>{{ $e | humanize }}</a>
{{- end -}}

Howto: Delimiter separated tags - tips & tricks, The example above uses tags with comma as delimiter, but this of course also applies to [solved] Delimited complete list of taxonomy terms? Add Tags to Your Hugo Blog Using Taxonomies November 21st, 2018. Since the inception of this blog, I've wanted to add "tags" to my posts. Readers could then browse a list of related posts based on a specific tag. Using Hugo's nifty taxonomies feature, I was able to easily built out that functionality.

Try this statement on li layout, this will show as a separate list with a link

{{ range $key, $value := .Params.categories }}
  {{if ne $value "null"}}
    <span class="tag-style-1"><a href="/tag/{{ $value | urlize  }}">{{ $value }}</a></span>
  {{end}}
{{ end }}      

Sane way to delimit content in a range? - support, Params.tags }} <div class="tags-list"> Tags: {{ $sort := sort . }} of slightly different lists—comma-separated, semicolon-separated, linking to different sections in a� I am new to Hugo, know nothing about GoLang and I am trying to do the following. Problem I have a Hugo site, and in my posts, I specify keywords in the front matter like: --- author: Andrea Tino

I have this workaround:

<strong>{{ Tags: }}</strong>
{{ range $key, $value := .Params.tags }}
   <a href="{{ "/tags/" }}{{ $value | urlize }}">{{ $value }}</a>{{ if ne $key (sub (len $.Params.tags) 1) }}, {{ else }}{{ end }}
{{ end }}

Code explanation: The comma for the last element will be skipped, this is, asking if the loop haven't reached the last element {{ if ne $key (sub (len $.Params.tags) 1) }}, until not, the comma will be printed. Note that here we're using the global operator $ to reach the global context for .Params.tags and avoid the context of the range loop <- This is important.

A more short approach could be this:

<strong>{{ Tags: }}</strong>
{{ range $key, $value := .Params.tags }}
   <a href="{{ "/tags/" }}{{ $value | urlize }}">{{ if $key }}, {{ end }}{{ $value }}</a>
{{ end }}

Code explanation: Hugo will be treat 0 as false, then, it will not print the comma for the first element and will be printed for the rest, behind the tag (ej: tag1 ,tag2 ,tag3). The problem of this approach is that the comma will be urlized too.

Add Tags to Your Hugo Blog Using Taxonomies, In this post we'll explore taxonomies in Hugo using blog post tags as an example. Using a taxonomy list template, you can render a list of blog posts that unordered list, with a link to each tag's list page (i.e. /tags/value_1 ). Configure Title Case . Set titleCaseStyle to specify the title style used by the title template function and the automatic section titles in Hugo. It defaults to AP Stylebook for title casing, but you can also set it to Chicago or Go (every word starts with a capital letter).

Do not show comma if there is only one tag on list page. � Issue #102 , <header class="main-header tag-head" style="background-image: url({{. <ul data-date="{{ $year }}{{ range first 1 (split . with <a class="icon-theme" href=" https://github.com/vjeantet/hugo-theme-casper">Casper</a> theme</section>. The go build flag -tags now takes a comma-separated list of build tags, to allow for multiple tags in GOFLAGS. The space-separated form is deprecated but still recognized and will be maintained. go generate now sets the generate build tag so that files may be searched for directives but ignored during build.

hamoid/long-hugo-doc: The documentation of the Hugo , The documentation of the Hugo static site generator in one long page. See themes.gohugo.io for a list of themes to consider. before the closing </body> in your templates and will therefore not work if this tag is not present. the ability to render your content to multiple output formats (e.g., to JSON, AMP html, or CSV). The default usage lists tags with each tag (if more than one) separated by a comma (,) and preceded with the default text Tags: . <p><?php the_tags(); ?></p> Separated by Commas Displays a list of the tags with a line break after it. <?php the_tags( 'Tags: ', ', ', '<br />' ); ?> Separated by Arrow Displays links to tags with an arrow

Taxonomy Templates, Taxonomy templating includes taxonomy list pages, taxonomy terms pages, and using Example: Comma-delimit Tags in a Single Page Template The following ranges over the full list of tags on your site and links to each of the seq � sha � shuffle � singularize � slice � slicestr � sort � split � string � strings. Free Comma Separating Tool. Do you often need to take a spreadsheet of data and convert to a comma-delimited list? Be it for taking a list of zip codes or names to make an SQL query, or to take data from a CSV and be able to paste into an array. At delim.co we make that just a little easier.