getTags(path) Last updated: 10. Aug 2026

Returns the tags stored on a document.

Tags share their storage with the full text search index, so they are always stored — and returned — as lower case single words. See addTag for what that does to a tag on the way in.

See also: addTag removeTag listFiles Tags are stored as search words

Parameters

Name Type Description
path string

Absolute path to the file, from the site root.

Returns

An array of strings — the document's tags, always in lower case. An empty array if the document has no tags, never null.

Throws an error if the path is empty, if it contains .. or a backslash, or if the file is not found. The error message names the path, so a loop that tags many files tells you which one failed.

Unlike addTag and removeTag, this function is not restricted to the API folder — the tags of a published file are already readable through listFiles and getFiles.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    /* Tags are always stored and returned in lower case */
    let tags = docly.getTags("/Invoices/Invoice 1001.docly");

    write("Number of tags: " + tags.length);

    for (let tag of tags)
    {
        write(chr(13) + " - " + tag);
    }
}#

Output

The #JS code above produces the output shown below:
Number of tags: 3
 - invoice
 - 2024
 - paid