Global Variables

Every single template is going to get loaded with the following variables:

now #

A DateTime object set to the current date and time.

Today is {{ now|date('M j, Y') }}.

siteName #

The name of your site, as defined in Settings → General.

<h1>{{ siteName }}</h1>

siteUrl #

The URL of your site. (See How Craft Determines the Site URL)

<link rel="home" href="{{ siteUrl }}">

currentUser #

A UserModel object set to the currently logged-in user (if there is one).

{% if currentUser %}
    Welcome, {{ currentUser.friendlyName }}!
{% endif %}

loginUrl #

The URL to your site’s login page, based on the loginPath config setting.

{% if not currentUser %}
    <a href="{{ loginUrl }}">Login</a>
{% endif %}

logoutUrl #

The URL Craft uses to log users out, based on the logoutPath config setting. Note that Craft will automatically redirect users to your homepage after going here; there’s no such thing as a “logout page”.

{% if currentUser %}
    <a href="{{ logoutUrl }}">Logout</a>
{% endif %}

Global Set Variables #

Each of your site’s global sets get GlobalSetModel object to represent them.

<p>{{ companyInfo.companyName }} was established in {{ companyInfo.yearEstablished }}.</p>