It's better when it's simple

User Tools

Site Tools


Tag Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" yes
  • 2020-07-29 "Hogfather" yes

plugin Assign category tags to wiki pages

Last updated on
Syntax, Helper, Action


The Tag Plugin lets you assign category tags to wiki pages.



Add a tag to the page

{{tag>[list of tags]}}
[list of tags] a space separated list of tags that describe the content of the current page required

Allows you to categorize your wiki pages. The resulting links either point to the corresponding page in the specified tag namespace (only if it exists). If you want a link to point to a page in another namespace, you have to indicate the namespace before the tag name. If this page doesn't exist, just the list of pages with the same tag is shown when you follow one of those links.


  • {{tag>tag1 tag2 tag3}}
  • with namespaces: {{tag>ns1:tag1 ns1:tag2 ns2:subns1:tag3}}
  • multiple word tags: {{tag>tag1_with_multiple_words tag2 tag3_part}}
  • {{tag>"tag with spaces" tag2}} – Within quotes you can use spaces. Tag is stored internally with underscores _.


List all pages with given tags.

[tag] the category tag for which you want a list of pages required
[flags] pagelist flags delimited by &, see flags optional

This displays a list of all pages that contain the given category tag. The list is sorted alphabetically by page ID. You can also prepend the modifiers + and -:

  • If you do not prepend, it acts as a OR. A page is added if it has one of these tags.
  • + creates an intersection between the list of pages created by the already defined tags and the pages matching the tag following the + (AND), so each listed page must have this tag.
  • - removes all pages tagged with the given tag from the list of already found pages (NOT).


  • {{topic>tag1 -tag2}} – Lists all pages tagged with tag1 but not with tag2.
  • {{topic>tag1 +tag2}} – Lists all pages tagged with tag1 and tag2.
  • {{topic>tag1 tag2}} – Lists all pages tagged with either tag1 or tag2 or both.
  • {{topic>ns1?tag1 tag2}} – List all pages inside namespace ns1 tagged with either tag1 or tag2
  • {{topic>.?tag1 tag2}} – List all pages inside the current namespace tagged with either tag1 or tag2
  • {{topic>tag1 tag2 tag3&nodate&desc&sort}} (Adding pagelist options to change the design)


Search form for filtering by tag.

[flags] pagelist flags delimited by &, see flags optional

This displays a search form with the possibility to select a namespace and to select tags from a table of all tags that should either be in- or excluded with the option to choose if the tags should be associated with AND or OR. The results are displayed as in the topic component.

This is a great feature which you should not miss. Please add a screenshot of this cool feature. FIXME

And you might check out TagFilter Plugin for similar purpose but in different scenarios.


  • {{searchtags}} – The basic syntax
  • {{searchtags&nodate&desc&sort}} – with pagelist options to change the design
  • {{searchtags&nonsform}} – hide the namespace selector


Shows a list of tags and its number of occurrences.

[tags] The tag for which you want to list the occurrence. Multiple tags separated by spaces. optional
&[namespaces] Counts occurrences for given tags only at pages inside the given namespaces. Multiple namespaces separated by spaces. optional

This part allows you to display an overview of your current used tags. It prints the tag and the related occurrence (how often is the tag used) in your wiki. Either you can specify a + (or empty) as tag-name, which results in a list of all used tags or just specify some tags separated by spaces.


  • {{count>+}} – List all tags with related occurrences.
  • {{count>tag1 tag2}} – List the occurrence of tag1 and tag2.
  • {{count>tag1 tag2 tag3&. ns1 ns2}} – List all occurrences for the given tags inside the namespaces (the dot . specifies the root namespace)
  • {{count>+&ns1 ns2}} – List all tags in ns1 and ns2.


Make link to the tag list


This displays a link to the listing of all tags as it is done by the Tag syntax but without tagging the page with that tag. With the optional dynamic flag the link becomes red when the listing of all pages with that tag is empty for the current user. The dynamic flag automatically disables the cache of the current page in order to ensure that the link color is always correct. Optionally a title can be specified that will be used as link name.


  • {{tagpage>test_foo}} – The basic syntax
  • {{tagpage>test_foo&dynamic}} – A link with dynamic link color
  • {{tagpage>test_foo|my title}} – A link with custom title
  • {{tagpage>test_foo&dynamic|my | title}} – A link with dynamic link color and custom title (that can also contain |)


The plugin can be configured with the DokuWiki configuration manager available in the admin menu.

namespace Namespace where the tag plugin looks for existing tag pages and links to them instead of the default tag overview. You could use the topic component {{topic>...}} to display the list of tags on such a page for example. The default value of namespace is: tag
sortkey Order in which tagged pages are sorted in the topic overview; available options are cdate as creation date, mdate as modification date, pagename, id as page ID, ns to sort pages before namespaces and title
sortorder Sort order of the topic overview (ascending or descending)
pagelist_flags Comma separated Flags of the pagelist plugin which is used to display the topic overview
toolbar_icon Show icon in page editor toolbar to add tags.
list_tags_of_subns When counting tags in specified namespaces include also tags in subnamespaces.
tags_list_css Choose tags list style between standard or optimised for top of page position.

Tagindex Rebuild

If the tag index becomes corrupted somehow (such as by using page move), then you can rebuild it by using the searchindex plugin or bin/indexer.php.

Demo / Screenshots

Topic listing: Tag overview

Tags: A page with tags


  • 2014-02-16
    • New and updated translations
    • Fixed tag searching with out of date indexes and numbers
    • Drop compatibility with DokuWiki versions older than 2013-05-10 “Weatherwax” in order to be able to use newer DokuWiki features
  • 2013-04-14
    • New sorting key “ns” which lists for each namespace first all pages in the namespace sorted by name and then all subnamespaces sorted by namespace name
    • Sort by page name (as displayed by the pagelist plugin) when no title exists and the sort key is title
    • In the topic syntax an implicit query for all pages is assumed if the query starts with a tag with “+” or “-”, this means that “+tag +tag2” is now the same as “tag +tag2” and that “-tag1” will return all pages without tag1.
    • The tagRefine-function (used by the blog plugin) now also supports tags without “+” or “-”
    • Revert the tag query change that was introduced in version 2012-08-24, before this change the query was executed as if all tags with a “+” or “-” were at the end while the documentation actually describes that the order matters. Each part of the query modifies the existing result set and either adds new pages (tag without “+” or “-”) or removes all pages with (“-”) or without a tag (“+”).
  • 2013-04-05:
    • New tagpage feature for creating a link to the list of all pages with a certain tag without tagging the page
    • Removed the Technorati ping feature as Technorati is no longer using any pings
    • zh-tw translation updated
  • 2013-02-15:
    • :!: fixed a security issue (XSS vulnerability), if you are using an older version of the tag plugin you should upgrade ASAP!
  • 2012-11-25
    • New searchtags feature, displays a search form for the topic syntax
    • Fix section edit button styles for the new dokuwiki template
    • In the topic syntax now really only namespaces and not pages are matched by namespace parameter
    • When sorting by the title the case is ignored now
    • The topic syntax of the tag plugin is now used instead of the topic syntax of the blogtng plugin when both are installed
    • Fix problems that tags could be missing when another page is rendered during the preview or when an old revision is diplayed
  • 2012-08-24
    • The tag plugin is now using the metadata index of DokuWiki instead of its own index for storing tags. Most plugins that need the tag plugin need to be adapted.
    • Tags are now normalized in the same way as page ids are normalized

Development changelog:

Sites using this Plugin

Feel free to add yours here:


How to use tags which consist of multiple words?

Just use an “_”, it gets automatically replaced by a “ ” i.e.:


Also, quotes seem to work:

{{tag>"tag with multiple words"}}

How to make the tag namespace breadcrumb still work

Let's use one of the example websites.

If you go to and then click in the breadcrumb “esperienze” you go to , an empty page. To make your pages inside the tag namespace always go to the tag list, add this to the beginning of your /.htaccess

This also allows you to keep your start page to add there, for example, the list of tags If your start page is not “start”, change it to the one you use

RewriteCond %{REQUEST_URI}            !tag:start
RewriteRule ^tag.([\-_a-zA-Z0-9\ ]*)$  tag:$1?do=showtag&tag=$1

Change CSS styles depending on existing tags

This colors the background of the page to red if the keyword 'deprecated' is specified as a tag.

function _handle_keywords(&$data) {
        global $ID;
        // Fetch tags for the page; stop proceeding when no tags specified
        $tags = p_get_metadata($ID, 'subject', METADATA_DONT_RENDER);
        if(is_null($tags)) return;
        // Replace underscores with blanks
        foreach($data->data['meta'] as &$meta) {
            if($meta['name'] == 'keywords') {
                $meta['content'] = str_replace('_', ' ', $meta['content']);
                // add extra styling
                $t = explode(',', $meta['content']);
                if(in_array('deprecated', $t)) {
                    $data->data['style'][] = array('type'  => 'text/css',
                                                     '_data' => '.dokuwiki .page {background-color: red;}');

Customizing the breadcrumbs

If you add at pagelist/helper.php

function tpl_youarehere2_help($id){
    $result = '';
    global $conf;
    global $ID;
    global $lang;
    // check if enabled
    if(!$conf['youarehere']) return false;
    $parts = explode(':', $id);
    $count = count($parts);
    // always print the startpage
    $result .= html_wikilink(':'.$conf['start']);
    // print intermediate namespace links
    $part = '';
    for($i=0; $i<$count - 1; $i++){
        $part .= $parts[$i].':';
        $page = $part;
        if ($page == $conf['start']) continue; // Skip startpage
        // output
        $result .= ' &raquo '.html_wikilink($page);
    // print current page, skipping start page, skipping for namespace index
    if(isset($page) && $page==$part.$parts[$i]) return $result;
    $page = $part.$parts[$i];
    if($page == $conf['start']) return $result;
    $result .= ' &raquo '.html_wikilink($page);
    return $result;
function tpl_youarehere2($id) {
    $str = $this->tpl_youarehere2_help($id);
    $pos = strrpos($str , '&raquo');
    if ($pos == -1)
    return $str;
    return substr($str, 0, $pos);
function addPage2($page) {
    $id = $page['id'];
    if (!$id) return false;
    $this->page = $page;
    $this->_meta = NULL;
    // priority and draft
    if (!isset($this->page['draft'])) {
        $this->page['draft'] = ($this->_getMeta('type') == 'draft');
    $class = '';
    if (isset($this->page['priority'])) $class .= 'priority'.$this->page['priority']. ' ';
    if ($this->page['draft']) $class .= 'draft ';
    if ($this->page['class']) $class .= $this->page['class'];
    if(!empty($class)) $class = ' class="' . $class . '"';
    $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF;
    if ($this->column['date']) $this->_dateCell();
    if ($this->column['user']) $this->_userCell();
    if ($this->column['desc']) $this->_descCell();
    foreach ($this->plugins as $plug => $col) {
        if ($this->column[$col]) $this->_pluginCell($plug, $col, $id);
    $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF;
    $this->doc .= DOKU_TAB.'<tr'.$class.'>'.DOKU_LF;
    $this->doc .= DOKU_TAB.DOKU_TAB.'<td style="padding-left:19px; padding-right:15px; padding-bottom:15px; font-size:10px;">';
    $this->doc .= $this->tpl_youarehere2($id);
    $this->doc .='</td>'.DOKU_LF;
    $this->doc .= DOKU_TAB.'</tr>'.DOKU_LF;
    return true;

And change tag/action.php

foreach ($pages as $page) {


foreach ($pages as $page) {

After that, the list of pages that contain the tag, except for the names of pages themselves under them will also be bread crumbs to these pages.

Bad appearance when displaying tags at top of page

:!: Integrated to main code (see tags_list_css) option

When you insert the syntax at the top of a wiki page, the output of the plugin will be displayed below the TOC (Table of Contents). To make the visual appearance more smooth, change your lib/plugins/tag/style.css to the following code:

div.dokuwiki div.tags {
  border-top: 2px dotted __border__;
  font-size: 95%;
  text-align: right;
/*  clear: both; */

How to change the word tag and topic to another language

Is it possible to change the word tag used in syntax to something else, like another language {{tagInMylanguage>someTag}} –damascene 2012/04/10

You need to add copy of the existing tag pattern, and modify it to

    $this->Lexer->addSpecialPattern('\{\{tag>.*?\}\}', $mode, 'plugin_tag_tag');
    //e.g. Spanish:
    $this->Lexer->addSpecialPattern('\{\{etiqueta>.*?\}\}', $mode, 'plugin_tag_tag');


Pagelist With Alphabetical Headers

Is there a way to group pages by the first letter of their name or header?

Something like the example in this post on the user forums?


Collapsible outline of all tags

My ideal tag “cloud” display would have an alphabetic list of all tags. Click on a tag to expand (unfold) the display, and it would show an alphabetic list of pages that include that tag. We would want typical flags, such as for specifying namespaces, and display (like nspages), plus limiting tags (perhaps with RegEx?).
–davidtango 2021-03-21

I want the description under the tag, is it possible to make a line brake or to get the description under the tag? Thx

Is there any tip for hierarchical tag? I try to categorize my pages. For example, there are two pages. A Persian cat page has {tag>animal:cat}. And a Dalmatian dog page has {tag>animal:dog}. If I write '{topic>animal}, I hope to see the two pages, but all I can see is blank. Yes, I can tag that {tag>animal dog}, {tag>animal cat}, but it is not fancy.

For bugs or feature requests, there is the bug tracker linked here : Bug tracker.

This plugin clashes with the include module of the mediasyntax plugin. One workaround is to disable that part of the mediasyntax plugin by renaming the include.php file.

If you have a tag name that is the same as a page name that already exists, the tag links will point to that page in the current namespace rather than the page name in the tag namespace. Is this a bug or a feature? (3-Aug-2011)?

Found the issue. If you do not specify a namespace, it defaults to whatever is defined as the default namespace (ie. root:tag). If you do specify a namespace, it makes whatever you specify as the location for the data file (ie. root:mynamespace), NOT root:tag:mynamespace.
  • Is there no way to display all used tags? This would be very useful for finding typos and (nearly) duplicate entries. (2012-02-21)
    • Sry, me stupid, it works with count… BUG except that the table-entries are empty in my wiki! Latest DW/Plugin, with ~~NOCACHE~~ Screenshot. Sry for not registering at github for this.
      • In most of my installation it works, in some not… clueless!
    • How to sort the taglist (count>+) alphabetical?

My wiki has about 7000 pages with tags. It takes 25 seconds to display ~~TAGCLOUD~~ (My server runs with latest NGINX, UBUNTU 12.04, 4 core i5 cpu with 8gb ram, intel SSD ). Anyone have any other suggestion? or Do I need SQL-based tagging solution? — S.C. Yoo 2014/04/19 06:02

Individual Search Form: I'd like a form where the user could just type in the tag name, click search, and then a list is generated below. I know you got the searchtags but its just going to get unwieldy with the amount of tags I'm envisioning having. Thanks

Structured Tags: Can this (or any other plugin) support structured tags in addition to free-form tags? – 2014-09-02

Blank pages

I'm using Dokuwiki under Debian, last version in Debian distro. I installed plugin tags, but don't work :(

All page with {{tag>name_tag}} results a blank page, including the content of the page. I don't know what don't work but, I can't use it :(

I am using Debian Wheezy and I am having the same issue.

»»»»» Hy, I think the tag should be separted by a “,”. I mean what happen if I wanna tag “New York City” ? In present is created separte tag for “new” “york” “city” and that's not really good. — A.V

Nothing was found.

Same here, get a Nothing was found page.

(2017-03-28) I had the same problem. By coincidence, I switched to the default Dokuwiki template for an unrelated reason and got a different error when I clicked a tag link: “Helper plugin pagelist is not available.” Installed the pagelist plugin and then it worked. This dependency needs to be documented.

SEO meta keywords

Does this plugin alter the meta tags of the rendered pages? If it doesn't, I would like to leave the suggestion. — Fabricio Rocha 2016-06-11 17:00

Sorting the {{count>}} results

Is there any way to sort the output of the {{count>}} command? I'd like to have a page of used tags in alphabetical order, but it seems that pagelist parameters are not supported. — Fabricio Rocha 2016-06-19 19:42

This can be achieved by editing the helper.php file of the plugin. Before the return $otag; line within the function tagOccurrences, just insert the line ksort($otags); and that's all. IMO this should be standard behavior. — Taylan

Unorderd List of all tags?

Is there a way to gen an unorderd list of all tags, similar as +, but without table and occurrences?

Filtering the list of Tags?

Hi, I have attempted to try an solve this but my apologies as I do not know enough about PHP. I use some tags on the site to create dynamic links and I was wondering if there is a way to have the tagsearch have the capability to ignore certain tags. In this case I start the dynamic tags with dw_ and would like to know if possible to filter out all the tags that start with dw_. Thanks for any help! Frank.

Add "*" to list all the tags under a tag namespace?

I need a function to add all the tags under a tag namespace to the tag list.
That is, when I have a ns1:tag1, ns1:tag2, …, ns1:tagN, I can use

{{topic> ns1:*}}

to show all the pages with the tag under the namespace ns1. It is quite useful because sometimes I just want to show the pages with a sub tag, but sometimes I want to show all the pages with these tags on a main page. Since the tags under ns1 may be added in the future, I do not need to change the main page code to add more tags.
Now the tag namespace cannot be managed, I hope the basic function can be added.

plugin/tag.txt · Last modified: 2024-01-19 23:43 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki