Symdiff returning duplicate content

After following the author pages implementation suggested by netlify, I’m trying to use the following query to show tags that match the same Author’s name.

{{ $contentWithTag := .Site.RegularPages.RelatedTo (keyVals "tags" .Params.name) }}
{{ $content := $contentWithTag | symdiff .Data.Pages }}
{{ with $content }}
	<h5 class="text-center title">{{ i18n "mentions" }}</h5>
	<div class="row">
		{{ range . }}
			{{ .Render "summary" }}
		{{ end }}
	</div>
{{ end }}

The thing is, right now it shows posts that belong to both .Data.Pages and $contentWithTag. Are these two collections different in a way that makes symdiff not work?

What happens in the first line? Could it be that .Params.name is empty for all? It has to be inside of a range through .Params.author, right?

I read that article too, but I wonder about some of the tips they gave there, like adding taxonomyTerm to disabled kinds if we don’t want to list authors… that would disable all taxonomyterms, not just authors. Maybe the article is not compatible with the current version.

Wait, are you saying it Hugo merges the two collections (slices, page objects, what ever the right term is here) and you are having author names coming up twice? In that case it’s because they are not the same type (collection, page objects, slices, …).

I should have pointed out that this is in list.html for authors and I am listing the posts where they are also tagged.

So yes, your second comment seems closer to what is going on. I should then convert one or both of them to slices ?

Yes, I think converting should help… But, read this here:

It might be easier to range through the .Pages part of .Site.Taxonomies.authors where the name is the current naem.

I believe I made some headway, but still haven’t figured it out completely.

If the front matter is this:

authors:
  - Bruno Amaral
tags:
  - Bruno Amaral

And the template code is:

{{ $contentWithTag := .Site.RegularPages.RelatedTo (keyVals "tags" .Params.name) }}
{{ $content := $contentWithTag | symdiff .Data.Pages }}
{{ with $content }}
	<h5 class="text-center title">{{ i18n "mentions" }}</h5>
	<div class="row">
		{{ range . }}
			{{ .Render "summary" }}
		{{ end }}
	</div>
{{ end }}

Otherwise, if the tag with the author name is not present, Symdiff will show the same post as in the previous list that only used .Data.Pages.

If symdiff produces the same page twice, and you’re sure they are the same and not just … similar, then it is a bug. It would surprise me a little, though.

Does this happen in both server and regular hugo?

yes, i just confirmed with a local build and the post is listed on both times. With and without symdiff

Bellow, where it says mentions, the page should only show the posts where the tag matches the author’s name but where the post’s author is different.

image

After checking with different types of query, it still looks like there is a bug with symdiff.

I have a repository where it can be reproduced:

git clone --depth 1 git@github.com:brunoamaral/DI-Public.git && cd DI-Public && git lfs pull

What is happening here is that I am trying to remove .Data.Pages from the output I get from tags matching that Author’s name.

The result is always duplicate unless the post also includes the tag that matches the author’s name.