Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Page specific content

Started by Luke 4 years ago · 2 replies · 673 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, 12 months ago
6 1218 12 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 974 1 year ago
Content & Markdown · by Jan L'Am, 2 years ago
4 851 2 years ago
Content & Markdown · by Leonardo, 2 years ago
3 775 2 years ago
Content & Markdown · by belthasar, 2 years ago
4 1189 2 years ago