# Why Content View and not a Partial?

**URL:** https://discourse.gohugo.io/t/why-content-view-and-not-a-partial/26912
**Category:** support
**Created:** [July 13, 2020, 12:06pm UTC](https://discourse.gohugo.io/t/why-content-view-and-not-a-partial/26912 "2020-07-13T12:06:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![danboyle8637](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/danboyle8637/32/11585_2.png) [@danboyle8637](https://discourse.gohugo.io/u/danboyle8637)
#### Post date: [July 13, 2020, 12:06pm UTC](https://discourse.gohugo.io/t/why-content-view-and-not-a-partial/26912/1 "2020-07-13T12:06:55Z")

</div>

I understand what a content view is but why would you use one over a partial?

---

<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: [July 13, 2020, 2:13pm UTC](https://discourse.gohugo.io/t/why-content-view-and-not-a-partial/26912/2 "2020-07-13T14:13:19Z")

</div>

There is a defined [lookup order](https://gohugo.io/templates/views/#which-template-will-be-rendered) for content views.

Let’s say you have three content types:

```txt
content
├── article
│ ├── article-1.md
│ └── article-2.md
├── photo
│ ├── photo-1.md
│ └── photo-2.md
└── video
    ├── video-1.md
    └── video-2.md

```

And, when displaying a _mix_ of content types on a list page, you want to format each item’s summary based on its type.

### Using Partials

layouts/\_default/list.html:

```html
{{ define "main" }}
  {{ .Content }}
  {{ range .Site.RegularPages }}
    {{ partial (printf "summary/%s.html" .Type) . }}
  {{ end }}
{{ end }}

```

Then create a directory structure for the partials:

```txt
layouts/
└── partials
    └── summary
        ├── article.html
        ├── photo.html
        └── video.html

```

### Using Content views

layouts/\_default/list.html:

```html
{{ define "main" }}
  {{ .Content }}
  {{ range .Site.RegularPages }}
    {{ .Render "summary" }}
  {{ end }}
{{ end }}

```

```txt
layouts/
├── _default
│ ├── baseof.html
│ ├── list.html
│ ├── single.html
│ └── summary.html
├── photo
│ └── summary.html
└── video
    └── summary.html

```

Notice that I did not define a “summary” content view for articles. When rendering an article it falls back to `_default/summary.html`.

Now, let’s say that I want the summary for photos to be different when rendering RSS pages:

```txt
layouts/
├── _default
│ ├── baseof.html
│ ├── list.html
│ ├── single.html
│ └── summary.html
├── photo
│ ├── summary.html
│ └── summary.rss.xml <--
└── video
    └── summary.html

```

### Additional References:

> [@What is different between .Render and partial?](https://discourse.gohugo.io/t/what-is-different-between-render-and-partial/17004):
>
> I think both of them are functions that copy code from other files to the working file. So what is the difference? And when should I use .Render (or partial)?

> [@Hugo Theme Engine: \`{{ .render }} \` vs \`{{ partial }}\`](https://discourse.gohugo.io/t/hugo-theme-engine-render-vs-partial/3018/):
>
> I am wondering what the real difference is, between including reusable html snippets in a hugo page tempate when using something like {{ .Render "single-item" }} vs using something like {{ partial "pagination.html" $paginator }} As far as I can tell, the single-item is a file that goes by the name ofsingle-item.html and that resides in the \_default folder, whereas pagination.html is a file that goes by the name of pagination.html and that resides in the \partial folder. I am seeing this co…

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)
#### Post date: [July 15, 2020, 2:13pm UTC](https://discourse.gohugo.io/t/why-content-view-and-not-a-partial/26912/3 "2020-07-15T14:13:30Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
