Using Taxonomies

I am trying to implement taxonomies for “industries”.

I put industry = “industries” in my config.toml under [taxonomies] and put industries = [“electronics”] in two content pages.

For example, the pages are:

/content/electronics.md and /content/case_studies/examplecorp.md

I want to include examplecorp,md in /content/electronics.md

I have tried copying and pasting the examples from the gohugo.io docs into the layout I am using for elecronics,md, but whatever variation I try does not work. (Nothing is displayed).

All that happens when I build the site is that I get a new folder, /industries, and /industries/electronics, and an index.xml file

Am I doing something completely wrong or am I just missing a step?

EDIT - after trying out some things, I managed to get the example for the docs working, which creates an unordered list with links in it (to all the pages with the industry of “electronics”). I wonder if it’s possible to actually include entire pages into a div of a layout - all the examples seem to be creating links to the actual page with the same taxonomy term, not including the actual content of those pages.

EDIT. Sorry for another edit, I managed to get the example of all keys and data being displayed as a list of links - I was wondering, how to reference the page title in the link? When I try .Params.Title I get a blank, and just .Title seems to be no different than .LinkTitle

I’m sorry - I figured this out.

In the unlikely event anyone else doesn’t know how to do this, use {{ .Content }} - I am still quite puzzled with {{ .Title }} doesn’t work, though. Any ideas?

(To clarify, .Title when used in range is the same as .LinkTitle - what if you wanted the Page Title as the link text)?

Having trouble following your question. Can you point to a repo or provide more code/template examples?

Hi, thanks for your reply @rdwatters.

Sorry to be obtuse. Let me try to explain.

Say I have a layout, secondary.html in /layouts/page/

I have a taxonomies list:

[taxonomies]
industry = “industries”

in config.toml

I have two pages, electronics.md and examplecorp.md

Both have

industries = [“electronics”]

in their Front Matter.

In my layout “secondary.html”, I have something like:

        {{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
              {{ range $key, $value := $taxonomy }}
                    {{ range $value.Pages }}                       
                        {{ .Content }}
                    {{ end }}
              {{ end }}
        {{ end }}

The basic idea is to have a bunch of secondary pages, with different industries, and display content from other pages with the same taxonomy name, in the page. For example, The “examplecorp.md” will just use a partial as a layout to display a small snippet of HTML to display the content of “examplecorp.md” within the “electronics” secondary page.

Look at this.

Thanks Mikhail - very interesting !

Have you had any success?

To clarify, the code I posted above DOES work, but it’s not exactly what I want, mainly because it puts in every page including the actual current page. I need to find a way to exclude the current page. I just wanted to know what the best way of doing this type of thing is, since obviously it’s not the above code :slightly_smiling:

I am using version 0.17, and what to do with 0.18, I do not know.