<p>In case anyone is wondering how you get the rest of the text – here is an example:</p>

<pre><code>{# Split paragraphs using a limit of 2 #}
{% set paragraphs = block.body|split('&lt;/p&gt;', 2) %}

{# Get first paragraph and add the missing closing tag  #}
{% set firstParagraph = paragraphs|first ~ '&lt;/p&gt;' %}

{{ firstParagraph|raw }}

{# The rest of the text is here, due to the limit in the split filter #}
{{ paragraphs|last|raw }}
</code></pre>

CC BY-SA 3.0
2016-02-19T17:04:26.377Z
2016-02-19T17:04:26.377Z
medoingthings
<p>Just for reference, if you use a regular Rich Text field for an optional custom Post Excerpt and a Matrix field (with a "text" field in it, among others) for the Post Body, you could check the custom excerpt for content and otherwise output the first paragraph of the text field in the first Matrix block of type textBlock: </p>

<pre><code>{% for entry in craft.entries.section('blog').find() %}

        &lt;h2&gt;{{ entry.title }}&lt;/h2&gt;

        &lt;div class="post-summary"&gt;
            {% if entry.postExcerpt | length %}
                {# Custom Excerpt #}
                {{ entry.postExcerpt }}
            {% elseif entry.postBody.type('textBlock').first() | length %}
                {# Auto Excerpt: in postBody Matrix, find first text block and extract first paragraph #}
                {% set first_block = entry.postBody.type('textBlock').first() %}
                {% set first_block_text = first_block.text %}
                {% set paragraphs = first_block_text|split('&lt;/p&gt;') %}
                {% set first_paragraph = paragraphs|first ~ '&lt;/p&gt;' %}
                {{ first_paragraph | raw }}
            {% endif %}
        &lt;/div&gt;
        &lt;p&gt;&lt;a href="{{ entry.url }}"&gt;Read More&lt;/a&gt;&lt;/p&gt; 

{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-07-03T19:29:10.503Z
2014-07-03T19:29:10.503Z
James Muspratt
<p>You can do this entirely with Twig.</p>

<p>First, use the <a href="http://twig.sensiolabs.org/doc/filters/split.html"><code>|split</code> filter</a> to split your HTML into an array of paragraphs, on their closing <code>&lt;/p&gt;</code> tags:</p>

<pre><code>{% set paragraphs = entry.myRichTextField|split('&lt;/p&gt;') %}
</code></pre>

<p>Then, you can assign the first paragraph to a new variable using the <a href="http://twig.sensiolabs.org/doc/filters/first.html"><code>|first</code> filter</a>. And don’t forget to bring back that missing <code>&lt;/p&gt;</code>.</p>

<pre><code>{% set firstParagraph = paragraphs|first ~ '&lt;/p&gt;' %}
</code></pre>

<p>Finally, you can output that. Use the <a href="http://twig.sensiolabs.org/doc/filters/raw.html"><code>|raw</code> filter</a> so that Twig doesn’t encode the HTML entities.</p>

<pre><code>{{ firstParagraph|raw }}
</code></pre>

CC BY-SA 3.0
2017-02-09T19:05:45.440Z
`{{ entry.body|split('</p>')|first|raw }}` seems to be working too
321zeno
CC BY-SA 3.0
2014-07-02T16:29:53.213Z
This outputs a strings like this:

"<p>This is outputted text</p>"

Is there an easy way to get rid of those <p> tags in that string or to make them actually format the text?
Allen Pieper
CC BY-SA 3.0
2014-07-02T16:32:14.400Z
@AllenPieper Sorry about that, forgot to include the `|raw` filter. Updated my answer.
Brandon Kelly
CC BY-SA 3.0
2014-07-02T16:16:53.900Z
2014-07-02T16:31:48.770Z
2014-07-02T16:31:48.770Z
Brandon Kelly
<p>I have a rich text output section I want to limit to the first paragraph so I can link to a full version on another page. What's the best way to do this?</p>

<richtext>
Is there a way to output only the first paragraph of a Rich Text field?
# Is there a way to output only the first paragraph of a Rich Text field?

(Asked by: username_0 on 2014-07-02)

I have a rich text output section I want to limit to the first paragraph so I can link to a full version on another page. What's the best way to do this?

**Tags:** richtext


---

## 3 answers

### Answer by username_3 on 2014-07-02. Score: 30 | Accepted answer

You can do this entirely with Twig.
First, use the |split filter to split your HTML into an array of paragraphs, on their closing  tags:
{% set paragraphs = entry.myRichTextField|split('') %}

Then, you can assign the first paragraph to a new variable using the |first filter. And don’t forget to bring back that missing .
{% set firstParagraph = paragraphs|first ~ '' %}

Finally, you can output that. Use the |raw filter so that Twig doesn’t encode the HTML entities.
{{ firstParagraph|raw }}

> **Comments:**
> **username_0**: This outputs a strings like this:  "<p>This is outputted text</p>"  Is there an easy way to get rid of those <p> tags in that string or to make them actually format the text?  
> **username_3**: @AllenPieper Sorry about that, forgot to include the `|raw` filter. Updated my answer.  
> **username_4**: `{{ entry.body|split('</p>')|first|raw }}` seems to be working too  

---

### Answer by username_1 on 2016-02-19. Score: 8

In case anyone is wondering how you get the rest of the text – here is an example:
{# Split paragraphs using a limit of 2 #}
{% set paragraphs = block.body|split('', 2) %}

{# Get first paragraph and add the missing closing tag  #}
{% set firstParagraph = paragraphs|first ~ '' %}

{{ firstParagraph|raw }}

{# The rest of the text is here, due to the limit in the split filter #}
{{ paragraphs|last|raw }}


---

### Answer by username_2 on 2014-07-03. Score: 5

Just for reference, if you use a regular Rich Text field for an optional custom Post Excerpt and a Matrix field (with a "text" field in it, among others) for the Post Body, you could check the custom excerpt for content and otherwise output the first paragraph of the text field in the first Matrix block of type textBlock: 
{% for entry in craft.entries.section('blog').find() %}

        {{ entry.title }}

        
            {% if entry.postExcerpt | length %}
                {# Custom Excerpt #}
                {{ entry.postExcerpt }}
            {% elseif entry.postBody.type('textBlock').first() | length %}
                {# Auto Excerpt: in postBody Matrix, find first text block and extract first paragraph #}
                {% set first_block = entry.postBody.type('textBlock').first() %}
                {% set first_block_text = first_block.text %}
                {% set paragraphs = first_block_text|split('') %}
                {% set first_paragraph = paragraphs|first ~ '' %}
                {{ first_paragraph | raw }}
            {% endif %}
        
        Read More 

{% endfor %}


---

