Docly Developers
Function Updated 23 Oct 2026

getFile(path, [includeMetadata])

Gets a single file with its data and metadata.

Parameters

pathstringrequired

Path of the file from the site root. If no file has that exact path, .hash, .html, /Index.hash, /Index.html and /Index are tried in that order — so a page or folder URL finds its file.

includeMetadatabooloptional

Default true: the document's fields merged with Docly's file metadata — the same object as getFiles gives with mode "Full". false: only the document's own stored values.

Returns

An object — see getFiles for the fields (mode "Full"). null when no file is found or the path contains .. or a backslash. Throws if the path is empty.

No access check is made. A document in an encrypted folder can only be read after unlockFolder.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
    let file = docly.getFile("Test files/Example file.xlsx", true);
    var json = JSON.stringify(file);
    
    // Format indent and line breaks in JSON
    var pretty = docly.formatJson(json);
    
    // Remove empty lines
    var html = pretty.replace(chr(13), "");
    
    write(html);
}#