Common Template Tags
Last updated Oct 27th, 2020 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn moreThis page lists the most commonly used MODX Revolution tags as an aid to anyone converting HTML/CSS layouts into MODX Templates. These are frequently referred to as "tags" or "placeholders" (and sometimes "template variables"), so we mention those terms here as an aid to searching, although technically speaking they are not placeholders or template variables: they are MODX tags. Yes, it can be confusing for the newcomer, so just remember that there are different flavors of these tags, each with its own purpose and name. Placeholders are set in code and are displayed with placeholder tags. Template Variables are extra resource content fields created by the user. They can be thought of as custom fields. Neither placeholders, not template variables are pre-set by the MODX core.
Default Resource Content Field Tags¶
In MODX Revolution, each page will always have the following content fields that you can use when constructing your templates. Except for the Resource ID and the parent field, they are all supplied by the user when editing the resource and may be empty if the user did not fill them in:
Tag | Description | Example Usage |
---|---|---|
[[*id]] |
the Resource ID of the page (set by MODX when the page is created. | Often used in conjunction with the link syntax, e.g. <a href="[[~[[*id]]]]">Bookmark this page!</a> |
[[*pagetitle]] |
the Title of the page. | <title>[[*pagetitle]]</title> |
[[*longtitle]] |
the Long Title of the page | <h1>[[*longtitle]]</h1> |
[[*alias]] |
the page alias. | Used to construct the URL of the page |
[[*description]] |
the page Description | <meta name="description" content="[[*description]]"/> |
[[*introtext]] |
the Introductory Text field (a.k.a. the summary). | Often used by Snippets to summarize posts, e.g. <div id="summary">[[*introtext]]</div> |
[[*parent]] |
the ID of the parent page (if any). Set by MODX when the page is created. Can be altered by the user. | Often used in conjunction with the link syntax, e.g. <a href="[[~[[*parent]]]]">Up to parent page</a> |
[[*menutitle]] |
the Title used when the page appears in menus. | Most frequently used by Snippets such as Wayfinder or pdoMenu when dynamically constructing menus |
[[*content]] |
the content of the page. | <body>[[*content]]</body> |
Other Common Tags¶
These tags represent system settings, which are editable under the System menu -> System Settings.
Tag | Description | Example Usage |
---|---|---|
[[++site_url]] |
Contains the URL for your site, e.g. http://www.yoursite.com/ | With many CMS's that rely on Apache rewrites, it's common practice to include a base tag in your HTML head: <base href="[[++site_url]]" /> |
[[++site_name]] |
Name of the site | ` |