# Detect if a more tag is in the markdown

**URL:** <https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644>\
**Category:** support\
**Created:** [December 19, 2017, 3:46pm UTC](https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644 "2017-12-19T15:46:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [December 19, 2017, 3:46pm UTC](https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644/1 "2017-12-19T15:46:37Z")

</div>

Hey there,  
Building my archive templates in my current project I will never use the default 70 words summary returned by default by Hugo.

Instead I will either use the front matters’ description OR whatever is before the `<!--more-->` tag. For this I need to test if the `<!--more-->` tag is present.

I assumed .Truncated would evaluate the presence of the `<!--more-->` but it does not, it seems to return true in any case which doesn’t make sense to me so apologies for I am obviously missing something.

I looked for the

That being said, is there any way to easily spot a `<!--more-->` tag in my content so I can choose between displaying whatever is before it, or in the case there are none, just the .Params.description ?

Thanks a ton!

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [December 19, 2017, 10:15pm UTC](https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644/2 "2017-12-19T22:15:04Z")

</div>

Have a look at the `split` template function.

Example: [Multiple Markdown-text-sections](https://discourse.gohugo.io/t/multiple-markdown-text-sections/4238/6?u=kaushalmodi)

Instead of `"<split>"` in that example, look for `"<!--more-->"`.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [December 19, 2017, 10:17pm UTC](https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644/3 "2017-12-19T22:17:19Z")

</div>

It should be faster to use `strings.Contains`.

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [December 19, 2017, 10:20pm UTC](https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644/4 "2017-12-19T22:20:00Z")

</div>

Yes, of course… I misread the question… @regis needs to just _test_ if that string is present, not extract the split elements…

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [December 19, 2017, 10:20pm UTC](https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644/5 "2017-12-19T22:20:57Z")

</div>

Thank you both!  
Still amazed by the reactivity of this community!

Cheers 🙂

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [December 20, 2017, 2:34pm UTC](https://discourse.gohugo.io/t/detect-if-a-more-tag-is-in-the-markdown/9644/6 "2017-12-20T14:34:10Z")

</div>

> [@bep](#):
>
> strings.Contains

Just dropping the Go Template usage here (you should test .RawContent and not .Content):

```
{{ if strings.Contains .RawContent "<!--more-->" }}
	{{ .Summary }}
{{ else }}
	{{ .Description }}
{{ end }}

```
