# Help needed: difference between .Plain, .PlainWords and plainify

**URL:** <https://discourse.gohugo.io/t/help-needed-difference-between-plain-plainwords-and-plainify/5681>\
**Category:** support\
**Created:** [March 4, 2017, 12:30am UTC](https://discourse.gohugo.io/t/help-needed-difference-between-plain-plainwords-and-plainify/5681 "2017-03-04T00:30:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 4, 2017, 12:30am UTC](https://discourse.gohugo.io/t/help-needed-difference-between-plain-plainwords-and-plainify/5681/1 "2017-03-04T00:30:39Z")

</div>

Trying to develop better documentation around these different methods/functions and I’m having a tough time distinguishing between the lot of them…

Also, any thoughts on how to differentiate these functions from `jsonify` or how to use in combination with `safe*` or `raw` (or whatever) would be greatly appreciated.

I think the distinctions need to be documentated after just recently (re)reading the following:

> **[\[SOLVED\] How to create a JSON index when there's code in content?](https://discourse.gohugo.io/t/solved-how-to-create-a-json-index-when-theres-code-in-content/4901/16)**
>
> Not sure what error message you refer to, but I fixed the "clipped off error messages" in Hugo 0.18.1. PlainWords is supported, not sure why it's undocumented.

Cheers.

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [March 4, 2017, 5:37am UTC](https://discourse.gohugo.io/t/help-needed-difference-between-plain-plainwords-and-plainify/5681/2 "2017-03-04T05:37:20Z")

</div>

`.Plain` is the Page content stripped of HTML tags as a **string**.

`.PlainWords` is the Page content stripped of HTML as a **[]string** (string slice). Under the hood, we’re using Go’s [strings.Fields](https://golang.org/pkg/strings/#Fields) to split `.Plain` into a slice.

`.RawContent` is the raw content read from the content file. Generally, this would be the raw Markdown content prior to any encoding from Hugo.

`plainify` is a template function that takes a given input, strips it of HTML tags, and returns a **string**.

`jsonify` is a template function that takes a given object, encodes it as JSON, and converts it to HTML-safe content.

The `safe*` family takes a given input and does a type-casting to the thing you want. For example, `safeHTML` can take a `string` as input, but returns a `template.HTML` type. Go HTML templates are context-aware. If you try to print a `string` with HTML tags in an HTML context, Go will escape all of the HTML tags. In that case, you need to convert the `string` type to `template.HTML` so that Go will leave it alone.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 4, 2017, 9:05am UTC](https://discourse.gohugo.io/t/help-needed-difference-between-plain-plainwords-and-plainify/5681/3 "2017-03-04T09:05:10Z")

</div>

Awesome, @moorereason. Thanks. Just the type of succinct description I needed. Now I can build some cool examples out around it. Cheers!

---

<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:** [March 4, 2017, 9:18am UTC](https://discourse.gohugo.io/t/help-needed-difference-between-plain-plainwords-and-plainify/5681/4 "2017-03-04T09:18:48Z")

</div>

Re. `RawContent`, its original use case was to use with client-side slide tools, i.e. Javascript rendering of Markdown.

---

<div class="post-metadata">

**Author:** ![richtera](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/richtera/32/12253_2.png) [@richtera](https://discourse.gohugo.io/u/richtera)\
**Post date:** [July 7, 2021, 8:46pm UTC](https://discourse.gohugo.io/t/help-needed-difference-between-plain-plainwords-and-plainify/5681/5 "2021-07-07T20:46:54Z")

</div>

I posted an issue I am having with plainify [Plainify problems (more of an opinion than a real defect) · Issue #8732 · gohugoio/hugo · GitHub](https://github.com/gohugoio/hugo/issues/8732) but there is a note to talk on discord first. I am sorry, never talked on discord yet, but I saw this related issue and another issue about jsonify of plainified text. Basically I see the need of always following plainify with htmlUnescape before using the value anywhere including jsonify. I have yet to be able to use plainify by itself and was curious if plainify should just do htmlUnescape internally because return safeHTML text would also work but would obviously be dangerous. The reason this came up is that when using plainify without htmlUnescape it seems to work until you happen to have any HTML entities in the string which end up being output as plain text instead of their unicode chars. So I end up constantly combing through the code searching for plaininfy without htmlUnescape, markdownify or safeHTML after it.
