Theme variable for content without title?

To display a pages content, the following theme variable is including in a template

{{ content|raw }}

Which includes the title and be body of text

You can also display just the title using

{{ header.title|raw }}

Is there a way to display just the body of text, without the title?

I have re-read the docs. Also a few searches here and I have either missed this, or didn’t find it.

thx

Isn’t content a body you want?

{{ content }} includes the page title and body of text (text below the line in the md file) I have updated the OP to clarify this.

@avolve, just use

{{ page.title|e }}
{{ page.content|raw }}

i assume you have something similar in your code

{% set content %}
    <h1>{{ page.title|e }}</h1>
    {{ page.content|raw }}
{% endset %}

and then
{{ content|raw }}

thanks @b.da

To clarify further, this is a modular page/template, Quark theme inheritance. And

{{ content|raw }}

and

{{ page.content|raw }}

generate the same output, including the title and body text.

Any tips own how/where I can set/reset page.content?

  1. clear the cache when you make changes to a modular template
  2. you need to be more specific, and share modular (if it modified) + module page file .md and template .html.twig (if we are talking about the module itself), so the community can help

Not sure what to suggest here… I have this in my modular templates and it doesn’t show title:

    <div>
        {% if page.header.show_title %}
            <h3>{{ page.title }}</h3>
        {% endif %}
        {{ content|raw }}
    </div>

I’m pretty sure you have a title in your main content. Something like:

---
some: header stuff
---

# Your title

And content

Appreciate the further suggestions.

The header for the md file includes

---
title: Leagues and Divisions
routable: false
menu: Teams
---

and the template.html.twig


{% set grid_size = theme_var('grid-size') %}

<section class="section modular-cards {{ page.header.class}} bg-gray">
    <section class="container {{ grid_size }} grid-lg">
      <div class="column col-12">
          {{ content|raw }}
      </div>
    </section>
</section>

As there is a title in the header,

{{ page.title|e }}

Will reproduce the title (as wanted). However

{{ content|raw }}

Produces both the title and body content. When I want to separate out the body content.

(I am adding some more fields to the template, and want to place the title above these, and body content below)

@avolve, You keep repeating that variable content contains the body and title of the page, while others claim it doesn’t, which I agree with.

{{ content|raw }} does not output the value of {{ page.header.title }}

Would you mind providing us some proof for your claim?

  • Please download the One-Page Site skeleton, which is a plain Quark based site containing a single modular page.
    The modular itself and each of its modules have a title set in the frontmatter/header of the file.
  • Could you show us where the title from the header of the modular page, or any of its modules, appears in the output (the generated HTML) of the page?

The only title I can find in the generated HTML is the title of the modular.md which appears in the <head> of the page.

I do appreciate the assistance (though your tone reads as passive aggressive and infers I am lying — which is not helpful).

Marking this as closed.

@avolve, I’m sorry you perceive my reply as passive aggressive. It certainly wasn’t intended that way.

I also don’t believe that you are lying. I do believe you are seeing something happening on your site that leads to the impression that {{ content }} contains the title.

Maybe me not being a native speaker made me use a sensitive tone of voice.

In an attempt to resolve the looping yes/no discussion, I wanted to go back to a default repeatable configuration to establish that {{ content | raw }} does, or does not, print the title from the header. After getting the yes/no out of the way, we can progress and help you getting the result you’re trying to implement.

2 Likes

Well… You’re definitely not telling a full story here. You say your MD has only header without body, but you see title AND the body in your content. You never provided how the body of your MD looks. Based on the resolution of the topic, I assume there was a # Title in your MD body

1 Like

@avolve, Despite the direction into which the discussion went, I’m curious if you found a solution to the issue. Would you mind sharing it?