Duplicate tags create duplicate posts in range

We have around ~12000 posts on digital.gov, and in the migration to HUGO we ended up with a lot of posts that have duplicate tags, for example here is an example of the tags (topics) from a post in our archive:

topics:
  - ux
  - design
  - accessibility
  - mobile
  - accessibility
  - ux

You can see that accessibility and ux are duplicated — which is causing them to be duplicated in on the page when we’re showing all posts tagged with accessibility.

Here is the simple range we’re using:

{{ range .Paginator.Pages }}
    ...article template goes here...
{{ end }}

What is the best way to go about this?
Should we:

  • try to use find/replace and regex to clean this up across 1200 files? :grimacing:
  • try to rewrite the range statement to remove any paginated files
  • use JS to remove duplicate posts from the listings? :grimacing:

I think the best way to go about fixing this is using a regex or find and replace in files if they all match the same pattern of:

- accessibility
- mobile
- accessibility

If they all match that you can do this very easily with your text editor or IDE otherwise regex would be the way to go. Filtering it out in the range is a band aid and you will still have the same issue if you would then migrate to something else in the future.

If you are going to spend time fixing it do it the right way :wink:

1 Like

@jeremyzilar, I looked for that example in the demo repo and didn’t the post or an example of a duplicate post. I was going to post something similar as @benmarte, and suggest: if it doesn’t show up that often, fixing the data might be the best choice, possibly as part of a general IA refresh (there are many, many tags on that site). :slight_smile:

1 Like