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

Page specific content

Started by Luke 4 years ago · 2 replies · 544 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, 9 months ago
6 458 9 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 437 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 367 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 295 1 year ago
Content & Markdown · by belthasar, 2 years ago
4 575 2 years ago