Make tags field case-insensitive

Apparently there used to be an option (lower or lowercase) for tags fields – but in the docs of Kirby 3 it’s not stated anymore.

In my opinion, it doesn’t really make sense when working with tags to distinguish between tag and Tag and TAG. Or am I missing something?

What would be the advantage? You can handle this in your templates and I don’t think all-lowercase tags are appropriate for every language. But as an option it could be useful, I guess.

At the moment you can add three tags—tag, Tag and TAG. It could happen that over time or different users working on one site use different cases for the same word.

When using autocomplete in the panel, filterBy and pluck in controllers / routes / templates, all three tags are handled as being different ones, although they are intended to be the same.

Maybe instead of forcing all lowercase tags, it would be better to have an option to ignore the case when using filterBy and / or pluck. I found a tweet of @bastianallgeier from 2015 supporting this idea but am not able to find this feature anywhere. Maybe I’m missing something here ?

Thank you for your reply!

What you can do to prevent having such issues:

$tag = 'OCEAN';
dump($page->children()->filter(function($child) use($tag) {
  $tags = $child->tags()->split(',');
  return in_array(Str::lower($tag), array_map('strtolower', $tags));

And you could do something similar when plucking values in blueprints, using the text/value options.

Or you could use a page.update:after hook to store tags in lowercase. Or override the tags field.

And add a feature request here:

But I agree, a lowercase option would be nice to have. It existed in Kirby 2.


I’ve created an issue in the ideas repo for this:

1 Like

A way to store this kind of information all lowercase makes sense if other services consume your Kirby 3 data. Fixing your template and controllers isn’t enough then as the data quality stays lower and thus will might cause troubles in future. I will upvote @LeBen’s ideas.

I am against the storage of “tags” in lower case letters, because in the German language there are many words, which have a different meaning with upper and lower case letters,
e.g. “Paar” (one men and one girl/woman) and “paar” (some).
Storing the same word would make the contents indistinguishable.

The suggestion of @texnixe is better to do this in the code.

I will also upvote this as an option that would be nice to have. As regards data quality, upper and lower case letters are not the only problems when it comes to using consistent tags, though, think typos. To be on the safe side, you would actually have to limit tags to a given set. I would like to keep the distinction of upper and lower case letters as the default, though.

@anon77445132 I think those cases are really negligible, nobody would ever use paar as a tag.

1 Like

because in the German language there are many words, which have a different meaning with upper and lower case letters

I know. That’s why I suggested it as an option (that already existed in Kirby 2). Using letters with diacritic marks is another problem (especially in German where words can have completely different meanings with or without diacritic marks) why tags can’t be used as freely anyways (for example in URLs).

On a sidenote:

“Paar” (one men and one girl)

An interpersonal couple is not limited to man and woman. Especially a “man” (“Mann”) and a “girl” (“Mädchen”) seem to be an inappropriate example to me.




I can answer end of this weekend.

But think of changing a running one language website to a website with adding e.g. the German language. In this case you will need to control your complete code handling tags.
If you have coded in a way, I said, your change will be more easy, I think.

I will answer end of this weekend, at the moment I’m not at home, sorry.
But I agree, my example was not good, but at that moment, I hat not enough time to look for a better example. It will be added…

1 Like

And think, that the German language has to follow the so called Duden, which says, which word has a capital letter in front.

The German language has to follow this rules. And for me all “tags” in a German language website too.

But that is my opinion, feel free to follow yours.

We will.


I just saw that the issue is still open and wanted to add that I really second an implementation of this option :~)

I’ve created a tagcloud for filtering pages by a format tag field like this

<?php foreach(page('archive')->children()->listed()->pluck("format", ",", true) as $format): ?>
    <a href="<?= url('/archive/format:' . $format); ?>">
        <div class="filter__button">
            <span class="button"><?= html($format); ?></span>
<?php endforeach; ?>

and in the frontend, I now have two filters for each i.e “statement” and “Statement” which is not wanted (especially because they’re all being text-transform: uppercase'd).

Do I use an update hook (and manually update all the existing content to be lowercase) or do you think there is a way to quickly add the option to ignore the case?

I think you have three options here:

  • Use a hook to make all string lowercase after saving
  • Use a page model to make all strings lowercase before saving
  • Use a page method that returns the content of the tags field in lowercase, then pluck this instead

Note that with the last option, you would have to reflect this when filtering, whereas the first two options actually change the stored values.

1 Like

Finally decided to go with option 3, since I realized I have to urlencode() the tags anyways to make for a nicer set of parameters – also like this I don’t have to touch any existing data and potentially delete anything by mistake :clown_face: