This sample shows how to create a template that automatically generates a unique document ID and link for any page.
The following is the source for the template:
<h1>Template:UID</h1>
<p>{{web.link(page.uri, 'Document #' .. page.id)}}</p>
The template uses the web.link function to create a link using the uri of the page (i.e. page.uri). The label for the page is generated by concatenating the string 'Document #' with the unique page ID (e.g. page.id). Note that the page variable in this case does not refer to the template, but the page that includes the template.
Now, simply invoke the template on any page as follows:
{{ template.uid() }}
The result looks as follows: