Hints on how to do this in a better way - future proof

Hi guys,

so I participated in this “100 days to offload” challenge and I have added a tag “100dto” to all the posts I wrote to automatically add a small piece of text at the bottom of the individual post. But now I want to go a second round, something like a second season.

I am looking for a more elegant way in writing my bit of code below.

The requirements are:

  • have a small piece of text added automatically to the blog post
  • number should be somewhere in the tags or somewhere else
  • should be future-proof, so I can go a third or fourth season without adding more blocks (if possible)
{{ with $.Param "100dto" }}
<p><i>Beitrag {{ $.Param "100dto" }} der ersten 
    <a href="https://100daystooffload.com" target="_blank" rel="noopener">#100DaysToOffload</a> Challenge.</i>
</p>
{{ end }}

{{ with $.Param "100dto2" }}
<p><i>Beitrag {{ $.Param "100dto2" }} der zweiten 
    <a href="https://100daystooffload.com" target="_blank" rel="noopener">#100DaysToOffload</a> Challenge.</i>
</p>
{{ end }}

If you have any idea if I could do this in a better way, I am open for suggestions.
I don’t mind updating tags on all past 100 posts if your solution suggests some other system.

Thank you very much.

If you envision a 3rd or more years, may be I would go for:

  • Use the challenge year in the front matter blog post
  • Use a global variable in config.toml
  • Have a partial testing those 2 variables.

post-2020.md

---
100ftoYear = "2020"
---

post-2021.md

---
100ftoYear = "2021"
---

config.toml

...
100ftoYearActive = "2021"
...

partial.html (not tested)

{{ if eq  .Params.100ftoYear site.Params.100ftoYearActive }}
<p><i>Beitrag {{ .Params.100ftoYear }} der ersten 
    <a href="https://100daystooffload.com" target="_blank" rel="noopener">#100DaysToOffload</a> Challenge.</i>
</p>
{{ end }}

Thank you very much for your answer. I tried this but it is not exactly what I want.
In the meantime I played a bit with taxonomies and I think this is the solution. I added a new frontmatter “categories”-tag to all posts and now I have all posts visible belonging to this category.

I totally missed this taxonomy thing because the theme I use had the disable rule set.

But your solution is also nice, but was not something I was looking for.