Skip to content
hertsch edited this page May 18, 2014 · 2 revisions

Check if the current page is the home page

The page ID of the home page - the page opened in browser if the blank URL of the website is typed into the address line of the browser - is stored in the constant PAGE_ID_HOME and the page ID of the current page is stored in the constant PAGE_ID.

If both ID's are identical, the current page is the home page.

Example php:

<?php
    if (PAGE_ID == PAGE_ID_HOME) {
        // the current page is the home page
        echo "<p>Welcome at xxx!</p>";
    }
?>

Example twig:

{% if PAGE_ID == PAGE_ID_HOME %}
    {# the current page is the home page #}
    <p>Welcome at xxx!</p>
{% endif %}

Cookbook | Next