HUGO

Related content does not always fetches related content

Repo can be found here.

  1. what you were doing or what you tried
  • I try to list content through custom categories (aka a perticular ‘exhibition’ eg. called ‘exhibition 1’). On the page of the specific term (e.g. ‘exhibtion 1’) I fetch all content. That works.
  • Each of these content items have ‘related content’. I used a custom param to define that related content. So in the config.toml I’ve created:

[taxonomies]
– tag = “tags”
– category = “categories”
– artists = “artists”
– type-artworks = “type-artworks”
– exhibition = “exhibitions”
– exhibition_type = “exhibition-types”
[related]
– includeNewer = false
– threshold = 1 #maybe need to be modified if using search results
– toLower = true
– [[related.indices]]
---- name = “artwork_refs”
---- weight = 100
---- includeNewer = true

  • To refer to each other, I add to the content items that need to be related a unique name, usually the name of the item I refer to. In other words in the front matter you will find:

Exhibition 1 - item 1
artwork_refs = "work_of_art_1"

And in the content item “Work of art 1”, you will find the exact ref, namely

artwork_refs = “work_of_art_1”

This is implemented so I can ‘reuse’ works of arts, when building a new exhibition (which is defined by adding a custom category to it, aka exhibition = “exhibitions”).

I use the following code to list the custom taxonomy terms.

<a-scene embedded arjs="sourceType: webcam; debugUIEnabled: false; detectionMode: mono_and_matrix; matrixCodeType: {{ .Params.marker_type_sets}};">
    <!-- Get some data before your process -->
    {{ $exhibition_type := .Params.exhibition_types}}
    {{ .Title }}
    {{ range .Paginator.Pages }}
        Eerste kunstwerk: {{ .Title }}<br>
        <!--  Get all the data from the exhibition item ref -->
        {{ $position := .Params.position_artwork }}
        {{ $size := .Params.size_artwork }}
        {{ $exhibition_marker_type_set := .Parent.Params.marker_type_sets }}
        {{ $marker_id := .Params.marker_id}}

        <!-- Now start fetching related content -->
        {{ range .Site.RegularPages.Related . }}

            {{ .Title }}
              <a-marker type="{{$exhibition_type}}" value="{{$marker_id}}">
                {{ .Title }}
                {{ .Params.artwork_refs }}
                <a-entity position="{{ $position }}" scale="{{ $size }}" gltf-model="/expo-dko/public/artworks/{{ .Params.model }}">
                </a-entity>
                {{ .Params.credits }}
              </a-marker>
            
        {{ end }}
    {{ end }}



<!-- add a simple camera -->
<a-entity camera></a-entity>
  1. what you expected
  • Every time I ‘create’ a new exhibition (aka category), I get a page listing all the ‘exhibitions items’. → Works fine
  • Using the related, I then pull the related content of the original work of art. → not consistent.
  1. what actually happened .
  • All category pages seems to be built properly.
  • related content is pulled only for specific ‘works of art’. Some are completely ignored, and not found to be related.
  • Creating a new exhibition using a custom category creates the page. When I relate the exhibition items with ‘good’ ’ works of art, the related content is shown. When relating them with ‘bad’ works of art, the related content does not show up.

I am having difficulty understanding the problem given the state and complexity of your project and my time constraints.

Perhaps you can create a small, simple test site that demonstrates the problem. This will often expose the underlying problem.

I understand that it might be confusing. To give a bit of context, I used to work with Drupal, where relationships is often at the heart of a site.

Anyways, allow me to further explain with a different set of examples.

Suppose you have a website with poetry. And that the poems we publish are often of the same authors. Each of the authors have a biography and a picture. Sometimes you build collections of poetry based on ‘moods’. So a collection would be ‘gloomy’, '‘happy’, ‘irritated’, ‘strange’.

In the content this would result in:

  • Authors
    – Author 1
    ----- Name
    ----- picture of author
    ----- Bio
    ----- author_ref: ‘author_1’
    – Author 2
    ----- Name
    ----- picture of author
    ----- Bio
    ----- author_ref: ‘author_2’

  • Poems
    – Poem 1
    ----- Title
    ----- author_ref: ‘author_1’
    ----- moods: [‘gloomy’, ‘strange’]
    – Poem 2
    ----- Title
    ----- author_ref: ‘author_2’
    ----- moods: [‘gloomy’, ‘irritated’]
    – Poem 3
    ----- Title
    ----- author_ref: ‘author_1’
    ----- moods: [‘happy’, ‘strange’]

  • With the related content of Hugo, I now am able to build a taxonomy list page for ‘gloomy’, ‘irritated’ and ‘strange’. The ‘strange’ list then pulls poem 1 and poem 3, the ‘gloomy’ lists poem 1 and poem 2.
    ---- This works fine.

  • Using the related content, I should be able to pull in (through the ‘author_ref:’) the related content of each specific poem, aka the author and all the params defined in the content. So on the ‘gloomy’ page I I should be able to pull in the .params.bio, the .params.picture_of_author…
    ---- This does not work. For some it does, for some ‘authors’ it works, for some other it does not.
    ---- Suppose that author 2 works and the related content using author 1 does not (aka for poem 1 and 3), changing the author on poem 1 to author 2, suddenly allows me to pull the related content of author 2. But it always fails with author 1.

Hope that is a bit more clear.

The above allows me to avoid rewriting redundant author info, and is a quick and easy way to build new lists using custom taxonomies.

The repo is a bit confusing, for it uses the ar.js lib to display 3d objects. But the data structure as described above is identical.