HASH files Last updated: 19. Aug 2026

.HASH files are text files such as HTML pages that execute on server side. They use JavaScript (#JS syntax - aka HashJS) code to process and bind data to your output files. The files must be static and will only be generated once. They will always be cached until the underlying data for the file has changed.

When to use

Use hash files when you are generating static content for your websites / webapps. Such as HTML, CSS, JSON or TXT files.

How to use

Create files in your published sites or in your site template with the file extension .hash

Test.hash

<html>
    <head><title>Test</title></head>
    <body>
        This is a test. By using the hash followed by curly I can write JS for server side generation:
        #{
            // This will run my javascript on server:
            var myValue = 10 + 10;
            write(myValue); // Write 20 to page
        }#
        
        If I simply want to bind a value I can use the shorthand without curly:
        #myValue# 
        
        Single statements only if no curly, don't end with ;
        This will bind the value of x to the page.
    </body>
</html>

The example above may not seem very useful. But it becomes very useful when you bind data to your pages from your Docly™ document database. Let's say you make a Docly™ Schema for a "Rental property". And make a HTML display template for it in a hash file:

<html>
    <head><title>Test</title></head>
    <body>
        Property name: #Name#
        Price: #format(Price, "N")#
        Image: <img src="#docly.linkImage(Image, 250, 250, 2)#" alt="Image" />
        Etc...
    </body>
</html>

Output is not escaped

A hash expression and a write() call both emit the value exactly as stored. Nothing is HTML-escaped for you, so a stored value containing markup is rendered as markup. Where the value is something a user can write, escape it at the point of output — otherwise you have a cross-site scripting hole.

Element content:   #docly.htmlEncode(Name)#

Attribute value:   <img alt="#docly.htmlAttributeEncode(Name)#" />

URL component:     <a href="?q=#encodeURIComponent(Name)#">...</a>

The two encoders are not interchangeable. htmlAttributeEncode() leaves the greater-than character unescaped, which is safe inside a quoted attribute and wrong for element content. Read more: Hash expressions do not escape HTML

The "Docly" function library connects your Javascript code to Docly™ data

Read about all the javascript functions and see examples here: JavaScript reference

Directives (SSI)

SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served.

Directive

Example

Description

Include directive

<!--#include file="...

Includes another file in this file.

Master file directive

<!--#master file="...

Uses another file as a master page. Read more: Setting up and using a Master Page