# How can I surround my paragraphs with \<section\> tags?

**URL:** <https://discourse.gohugo.io/t/how-can-i-surround-my-paragraphs-with-section-tags/34280>\
**Category:** support\
**Created:** [August 16, 2021, 3:11am UTC](https://discourse.gohugo.io/t/how-can-i-surround-my-paragraphs-with-section-tags/34280 "2021-08-16T03:11:00Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [August 16, 2021, 7:55pm UTC](https://discourse.gohugo.io/t/how-can-i-surround-my-paragraphs-with-section-tags/34280/5 "2021-08-16T19:55:55Z")

</div>

To answer your original question…

layouts/\_default/\_markup/render-heading.html

```auto
{{ if eq .Level 2 }}
  {{ printf "<!-- end-chunk -->" | safeHTML }}
  {{ printf "<!-- begin-chunk data-anchor=%q -->" .Anchor | safeHTML }}
{{ end }}
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}</h{{ .Level }}>

```

template

```auto
{{ range (findRE `(?s)<!-- begin-chunk.*?(?:<!-- end-chunk -->|$)` .Content) }}
  {{ $anchor := replaceRE `(?s).+data-anchor="(.+?)".+` "$1" . }}
  {{ $section := replaceRE `(?s)<!-- begin-chunk.+?-->(.+?)(?:<!-- end-chunk -->|$)` "$1" . }}
  {{/* Remove leading and trailing newlines. */}}
  {{ $section = trim $section "\n" }}
  <div id="{{ $anchor }}">
  {{ $section | safeHTML}}
  </div>
{{ end }}

```

> **This produces something like...**
>
> ```auto
> <div id="section-1">
> <h2 id="section-1">Section 1</h2>
> <p>This is <strong>section</strong> 1.</p>
> <p>This is section 1.</p>
> 
> <h3 id="section-11">Section 1.1</h3>
> <p>This is <strong>section</strong> 1.1.</p>
> <p>This is section 1.1.</p>
> 
> <h3 id="section-111">Section 1.1.1</h3>
> <p>This is <strong>section</strong> 1.1.1.</p>
> <p>This is section 1.1.1.</p>
> </div>
> 
> <div id="section-2">
> <h2 id="section-2">Section 2</h2>
> <p>This is <strong>section</strong> 2.</p>
> <p>This is section 2.</p>
> </div>
> 
> <div id="section-3">
> <h2 id="section-3">Section 3</h2>
> <p>This is <strong>section</strong> 3.</p>
> <p>This is section 3.</p>
> </div>
> 
> ```

---

_[View the full topic](https://discourse.gohugo.io/t/how-can-i-surround-my-paragraphs-with-section-tags/34280)._
