I have similar tags, for example: Drones and drones. How can I delete one of them, because the cms show them like different taxonomy
I guess you donāt really want to delete a tag, but just consolidate, in your Example, convert ādronesā to āDronesā or vice versa, right ?.
In that case, you can use a text Editor which can replace strings in files, recursively.
or, if your development PC runs linux, you can use sed:
find . -type f -name "*.md" -exec sed -i 's/\- drones/\- Drones/' {} \+
hint: omit the option -i for sed for a first run, so you can see what will be changed
This is an interesting issue I have not encountered before. Are you seeing the duplicate versions of the tag (ādrones/Dronesā) in Admin or using a code editor?
Do you have any idea how the two forms of the tag got in there?
I thought Grav tags were case-insensitive. I must be mistaken.
Iām just saying Iād be interested to hear more details about this problem. Could be a bug.
Taxonomies are case-sensitive.
Have a look at the code that adds taxonomy/values to the taxonomy_tree when looping through all pages: Taxonomy::addTaxonomy() lines 59-86
The taxonomy tree has the following structure: [taxonomy_type][taxonomy_value][page_path]
For example:
[category][blog][path/to/item1]
[tag][grav][path/to/item1]
[tag][grav][path/to/item2]
[tag][dog][path/to/item3]
Case insensitivity has been requested before, but didnāt get much follow up: Make URL Taxonomy Filter Case Insensitive? #2285
If one wants to fix mixed cases of the same taxonomy value, the script proposed by @hoernerfranz might come handy.
If one wants to prevent mixed cases being entered in Admin, one can create a plugin, catch the Admin āsaveā task and convert the taxonomies available in the header of the page into the preferred case.
Anyone interested in creating a TaxonomyCaseGuard plugin? The plugin might implement as a bonus a CLI command performing a search/replace to fix existing mixed cases.
Yes, if it is possible convert ādronesā to āDronesā or vice versa. But I am a Windows (
well, for windows I can recommend Visual Studio Code, which can replace strings recursively in a file tree.
Thanks, but to me it sounded like: if you canāt swim, jump in the water Maybe can someone make a short guide on how and what to do? Please
oh, well, here is a short recipe:
- install VS Code on your computer
- if you donāt have a local copy of your blog pages, create a backup in your grav admin panel
- download and unpack this backup
- open the folder user/pages in VS Code
- do a search/replace in files, choose case sensitive
- upload the changed files to your web server
done
OK, here is a proof of concept for the plugin I suggested.
What can it do:
- CLI
-
$ bin/plugin taxonomy-case-guard set-case --case capitalize
# one of capitalize|uppercase|lowercase
This command will loop through all pages and will replace each and every taxonomy value to the preferred case. -
$ bin/plugin taxonomy-case-guard replace --search category.blog --replace Blog
This command will search for pages with taxonomycategory.blog
and will replace the value withBlog
-
- Admin
- When saving a page, the taxonomy values in the header will first be converted to the preferred case (as set in config file).
After any update, the taxonomy values will be dedupped.
Here is the repo: GitHub - pamtbaau/grav-plugin-taxonomy-case-guard
Disclaimer:
- Will it have bugs? Sure, it is a proof of conceptā¦
- Test it before using it on a production server.
- I will not add the plugin to GPM myself, but be my guest to fork and submit it.
- I will not provide any further support on the plugin, no fixes, not feature requests, no ā¦
This option helped me: find and replace via VS Code. Unfortunately, the plugin from the pamtbaau did not help me, because diamonds appeared in Cyrillic instead of letters. But I think this plugin from the pamtbaau will be helpful to others. Thank you all for your help! Have a good weekend for all!