
# Accessing page data in Velocity

> A beginner's walkthrough of reading page data inside Cascade Velocity Formats: global variables, built-in metadata, dynamic metadata fields, and the most common page asset properties.

URL: https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/accessing-page-data-velocity.html
category: Developing in Cascade
article-type: how-to
content-kind: article
release-availability: all
tags: metadata, velocity
updated: 2026-10-06

When you write a Velocity Format in Cascade, most of what you do boils down to one question: *how do I get at the data on the page?* This guide covers the basics: the global variables Cascade provides for free, the built-in and custom metadata fields available on every page, and the page properties you'll use most often. Almost everything starts with `$currentPage`, so that's where we'll begin.

## Global variables

Cascade exposes a handful of global variables in every Velocity Format. You don't need to `#set` them or import anything. They're just there.

**Global variables available in Velocity Formats.**

| Variable | Output Type | Description |
| --- | --- | --- |
| `$contentRoot` | Element | Returns a JDOM Element containing the XML supplied for the current region. |
| `$currentPage` | PageAPIAdapter | Returns the current page as an API object. |
| `$currentPagePath` | String | Returns the path of the current page. |
| `$currentPageSiteName` | String | Returns the name of the current page's site. |
| `$enabledCustomDirectives` | ArrayList | Returns all available custom directives in the CMS environment. |

Of these, `$currentPage` is the most important, and the one you'll use most. Unlike the others, which return a single value, `$currentPage` hands you the entire page as an object you can dig into: its metadata, structured data, path, parent folder, tags, and more.

Here's what each variable looks like when you print it directly:

```velocity
$currentPage
## com.hannonhill.cascade.api.adapters.PageAPIAdapter@3fc3692

$currentPagePath
## /path/to/index

$currentPageSiteName
## My Site
```

`$currentPage` prints as an object reference because it *is* an object. You need to ask it for something specific (its title, its path, a structured data node) to get a value out. The other two are already strings, so they print as-is.

> **Pro Tip**
>
> Don't reuse these names as your own variables. If you write `#set ($currentPage = ...)`, you've just shadowed the original, and there's no way to get it back in that scope.

For the full list of Velocity Tools and global variables, see [Velocity Tools](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/velocity-tools.html).

## Accessing built-in metadata

Every page has a Metadata Set attached to it, and the built-in fields from that set are reachable through the `metadata` property on `$currentPage`:

```velocity
$currentPage.metadata
```

That returns the metadata object on its own, which isn't much use yet. Chain a field name onto it to read a specific value:

```velocity
$currentPage.metadata.title
## Accessing Page Data in Velocity

$currentPage.metadata.displayName
## Accessing Page Data

$currentPage.metadata.description
## A short summary of the page.

$currentPage.metadata.startDate
## Wed Feb 18 00:34:00 EST 2026
```

Notice the format of `startDate`. That's the default `Date` object's `toString()` output. To control how it's displayed, use the Date Tool's formatting methods. See [Date Tool Essentials](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/date-tool-essentials.html) for the patterns.

The other built-in fields follow the same pattern:

```velocity
$currentPage.metadata.summary
$currentPage.metadata.teaser
$currentPage.metadata.keywords
$currentPage.metadata.author
$currentPage.metadata.endDate
$currentPage.metadata.reviewDate
```

> **Pro Tip**
>
> Notice the pattern: each `.` takes you one level deeper into the asset's data. This is called *dot notation*, and you'll see it everywhere in Cascade Velocity. The more properties you chain together, the more specific the data you can access (when available).

## Accessing dynamic (custom) metadata

Custom metadata fields (the ones defined on the Metadata Set beyond the built-ins) work a little differently. Instead of being available as a direct property, they're accessed through a **method**:

```velocity
$currentPage.metadata.getDynamicField("example-name")
## com.hannonhill.cascade.api.adapters.DynamicMetadataFieldImpl@1357674b
```

The string you pass in is the field's **Name** value from the Metadata Set (not its label). What you get back is the field *node*. To get the actual value, chain the `value` property onto it:

```velocity
$currentPage.metadata.getDynamicField("example-name").value
## example value
```

> **Pro Tip**
>
> Notice the difference between a property and a method. A property is accessed with just `.name`, while a method uses parentheses and can accept arguments, like `.name(args)`. Both patterns appear throughout Cascade Velocity.

For details on configuring custom metadata in the Cascade UI, see [Metadata Fields](https://www.hannonhill.com/cascadecms/latest/articles/design-in-cascade/metadata-sets/metadata-fields.html).

## Commonly used page properties

`$currentPage` exposes far more than just metadata. Here are the properties you'll reach for most often:

```velocity
#set ($label = $currentPage.label)
#set ($url = $currentPage.link)
#set ($path = $currentPage.path)
#set ($parentFolderPath = $currentPage.parentFolder.path)
#set ($siteName = $currentPage.site)
#set ($dataDefinitionName = $currentPage.dataDefinition.name)
#set ($assetType = $currentPage.assetType)
#set ($systemName = $currentPage.name)
#set ($systemTags = $currentPage.tags)
```

> **A note on `.label`**
>
> `.label` uses Display Name first, then falls back to Title if Display Name is empty, then to System Name if both are empty. That makes it a safe choice when you want a human-readable label for the page without writing fallback logic yourself.

## Discovering what's available with the Property Tool

How do you know what properties and methods `$currentPage` (or any other object) supports? Use the Property Tool. Its `outputProperties()` method lists everything an object exposes, along with the type of data each one returns:

```velocity
$_PropertyTool.outputProperties($currentPage)
```

The output looks something like this (trimmed for readability):

```
Object type: com.hannonhill.cascade.api.adapters.PageAPIAdapter
Properties:
 - assetType: String
 - contentType: ContentType
 - dataDefinition: StructuredDataDefinition
 - getStructuredDataNode(String): StructuredDataNode
 - label: String
 - link: String
 - metadata: Metadata
 - name: String
 - parentFolder: Folder
 - path: String
 - site: Site
 - structuredData: StructuredDataNode[]
 - tags: List
```

The Property Tool is the fastest way to answer "what can I do with this object?". Point it at anything (a page, a folder, a structured data node, a chooser asset) and it will tell you.

> **Pro Tip**
>
> The Property Tool lists *possible* properties based on the object's type, not what's actually populated. For example, it will show `.value` as a property when called on a group structured data node, but groups don't have a value of their own (their data lives in their children), so the result is empty. Treat the output as a map of what's reachable, not a guarantee of what's there.

For the full Property Tool reference, see [Velocity Tools](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/velocity-tools.html).

## Next: reading structured data nodes

Metadata and page properties are only part of the picture. Every page also has structured data defined by its Data Definition, the content fields you fill in when editing a page. Reading those uses a different set of methods: `getStructuredDataNode()` for top-level nodes and `getChild()` for anything nested underneath.

See [Accessing data definition nodes in Velocity](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/accessing-data-definition-nodes-velocity.html) for the full walkthrough.

## Related articles

- [Accessing data definition nodes in Velocity](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/accessing-data-definition-nodes-velocity.html)
- [Velocity Tools](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/velocity-tools.html)
- [Best practices for performance](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/velocity-best-practices.html)
- [Variable scope in Velocity](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/velocity-variable-scope.html)
- [Metadata fields](https://www.hannonhill.com/cascadecms/latest/articles/design-in-cascade/metadata-sets/metadata-fields.html)
- [Date Tool essentials](https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/date-tool-essentials.html)
