I’ve had it on my bucket list for quite some time now but today I finally got around and introduced tagging posts on my website.

Since I’m using Processwire, setting up a new field for tags and displaying them in my templates was a matter of minutes. At first I thought about using a simple text field and store the tags as a string of comma separated values. But that seemed a bit hacky and laborious to maintain.

I went for another approach: each tag is represented by a page that is stored and hidden in a container page named “tag collection”. To assign tags to a page, I then use a page field that retrieves all pages from my tag collection container and allows storing multiple pages as well as creating new pages on the fly. I also installed the core module Page Autocomplete which makes adding existing tags (or pages) even easier.

I guess this approach can be used for other scenarios as well but it is certainly suitable for storing tags in Processwire. At least that’s what I learnt today.