The Debug Variable
As of v1.7.6, Statamic now creates a {{ _debug }}
variable on every page. This variable is a named-list, which currently contains the following information:
layout
is the layout that was used to render the current pagetemplate
is the template that was used to render the current pageenvironment
is the environment that was matched and is being usedtheme
is the theme being usedstatamic_version
(renamed fromversion
in v1.7.9) is the version of Statamic being used by the current sitephp_version
(added in v1.7.9) is the current PHP version being used by the site
Using _debug
A useful idea for displaying debug information is to dump it into an HTML comment at the top of your pages when in a development environment. First, you’ll want to set up a development environment. For this example, let’s assume that our environment matches a dev
environment.
Next, at the top of your default layout file, just inside of your HTML tag, put the following:
<html>
{{ if is_dev }}
<!--
debug information
---------------------------------------------------------
{{ _debug|dump }}
---------------------------------------------------------
-->
{{ endif }}
Now refresh your page and view the source. (You can also view the source of this page, we’ve added the _debug
stuff to it just for you to look at.)
You can also access any of the individual _debug
variables with the colon-syntax, for example, the current template can be displayed with {{ _debug:template }}
.