ExpressionEngine

2.5.5 User Guide

Path Variables

The Path variable is one of the most commonly used variables within templates. It’s purpose is to enable you to easily create links to other templates within your site. Here is the basic format:

{path='template_group/template'}

Make sure you substitute “template_group” and “template” with the name of an actual template group and template.

When the path variable is rendered it will automatically include your site URL, as you’ve defined in your General Configuration.

For example, a variable like this:

{path='channel/comments'}

Will be rendered like this:

http://example.com/index.php/channel/comments/

The path variable is most commonly used to create a link, like this:

<a href="{path='channel/archives'}">My Archives Page</a>

Why not hard code URLs instead?

The biggest advantage to using the path variable whenever you must create a link is that if your site URL ever changes you can simply update your General Configuration page with the new URL and every link in your templates will update accordingly. Using the path variable is also less prone to errors since you only need to know two pieces of information: The Template Group name and the template name.

Other Path Variables

There are several other “path” variables for specific purposes:

Site Index

You can use site_index in your path to point to your main site index:

{path='site_index'}

Log-out

Using logout in your path variable will let you create a link that logged-in members can used to log out with:

{path='logout'}