Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Page specific content

Started by Luke 4 years ago · 2 replies · 460 views
4 years ago

I would like to display content that is not shown on the home page, but is shown on all other pages. Is there a solution how to insert this in a theme template part?

4 years ago

You can create in your theme an .html.twig template exclusively for the home page and another template for a standard page. This way you will control what you want to be shown and what not.

Does this help you?

last edited 09/02/22
4 years ago

Hi.

You can use a block to display this content in which it is displayed if the page is different from the home page. For example:

TWIG
{% if not page.home() %}

{% block specific_content %}

{% endblock %}

{% endif %}

On all other pages you just have to wrap the content you want to display inside this block.

Example with page1.htm.twig:

TWIG

{% block specific_content %}

Your content here

{% endblock %}

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 94 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 146 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 60 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 254 1 year ago