getTags(path) Last updated: 11. 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 getAllTags listFiles Tags are stored as search words

Parameters

Name Type Description
path string

Path to the document, from the site root. This is the published path, so it follows the same rules as a link: a schema-bound document is addressed without its .docly extension, while a schemaless document keeps its .json. Passing "/Invoices/Invoice 1001.docly" throws File not found; "/Invoices/Invoice 1001" is correct. The leading slash is optional.

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.
#{
    /* Note the path: no .docly extension on a schema-bound document */
    let tags = docly.getTags("/Invoices/Invoice 1001");

    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