Page url

On this page:


<txp:page_url />

The page_url tag is a single tag that is used to return a particular component of the URL from the current page being displayed.


Tag will accept the following attributes (case-sensitive):

default="value" v4.7.0+
The default value if no component of the current page’s URL matches the type attribute.
Default: unset.
type="type" v4.7.0+
Specifies which component of the current page’s URL will be returned.
admin_root: current site’s admin URL.
author: current page’s author on article lists filtered by author.
c: current page’s category.
css: current style sheet name.
id: current article’s id on a single article page.
images_root: images directory URL.
month: current page’s month on time based article lists.
page: current page template name.
pg: current page number in article list mode.
q: search query string.
request_uri: current article’s URL-title including any query string.
s: current page’s section.
status: HTTP error response (200, 404).
theme: current theme name.
theme_path: current theme directory URL.
themes_root: themes directory URL.
Default: request_uri.

Any other type value will return the matching URL component or the default value that will always be sanitized. v4.7.0+


Example 1: Show the current article’s ID, HTTP status and section

    Article ID:
    <txp:page_url type="id" />,
    From section:
    <txp:page_url type="s" />
    (Result: <txp:page_url type="status" />)

This would result in the following, for example:

    Article ID:
    From section:
    Tasty pea recipes
    (Result: 200)

Example 2: Show the current theme’s name and path

    Using theme '<txp:page_url type="theme" />' located in <code><txp:page_url type="theme_path" /></code>

This would result in the following, for example:

    Using theme 'four-point-seven' located in <code></code>

Example 3: Show the website’s image and themes directories

    Site images are located in <code><txp:page_url type="images_root" /></code> and themes are located in <code><txp:page_url type="themes_root" /></code>.

This would result in the following, for example:

    Site images are located in <code></code> and themes are located in <code></code>.

Example 4: Return the sanitized value of some URL component

<txp:page_url type="lang" default="en" />
<link rel="stylesheet" href="<txp:page_url type="theme_path" />/styles/default.css">
<script async src="<txp:page_url type="theme_path" />/scripts/main.js"></script>


Version 4.7.0

type attribute behaviour changes (value will always be sanitized).
images_root, theme, theme_path and themes_root values allowed for type attribute.
default attribute added.

See something wrong in this document? Outdated info, a broken link, faulty code example, or whatever? Please open an issue and we’ll investigate.