# Summary on home page

**URL:** <https://discourse.gohugo.io/t/summary-on-home-page/36828>\
**Category:** support\
**Created:** [January 28, 2022, 5:48pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828 "2022-01-28T17:48:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prat](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Prat](https://discourse.gohugo.io/u/Prat)\
**Post date:** [January 28, 2022, 5:48pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/1 "2022-01-28T17:48:30Z")

</div>

Can we have an option where I continue to use `{{ .Content }}` and yet have an option to truncate posts at the point where I specify the `<!--more-->` tag in my posts?

Using `summary` truncates all posts on the homepage.

---

<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:** [January 28, 2022, 6:13pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/2 "2022-01-28T18:13:57Z")

</div>

> [@Prat](#):
>
> Using `summary` truncates all posts on the homepage.

As written, this is false.

The `.Content` of your home page is determined by what appears beneath front matter in `content/_index.md`.

The `.Summary` of your home page is determined by the [method](https://gohugo.io/content-management/summaries/#summary-splitting-options) used to define it.

Regardless of the method used to define the `.Summary`, it will only include content from `content/_index.md`.

---

<div class="post-metadata">

**Author:** ![Prat](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Prat](https://discourse.gohugo.io/u/Prat)\
**Post date:** [January 28, 2022, 7:14pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/3 "2022-01-28T19:14:57Z")

</div>

I see what you mean. Thanks for the extra information that helped me understand better.

This is what I have in my `/layouts/index.html`:

```auto
{{ define "main" }}
	{{ $posts := where site.RegularPages "Type" "post" }}
	{{ $grouped := $posts.GroupByDate "2006-01-02" }}
	{{ $paginated := (.Paginate ($grouped)) }}
	<main class="content" role="main">
		{{ range $paginated.PageGroups }}
		{{ $thedate := (time .Key) }}
		<h3 class="post-group"> {{ $thedate.Format "January 2, 2006" }}</h3>
  		{{ range .Pages.Reverse }}
    	{{ if eq .Type "post" }}
      		{{ .Render "article" }}
    {{- end }}
  {{ end }}
{{ end }}
</div>
{{ partial "pagination.html" . }}
{{ end }}

```

So I then head to the `/layouts/post/article`, I have this:

```auto
<article class="h-entry post">
	<header class="post-header">
    {{ with .Params.image }}
      <img class="u-featured" src="{{ . }}"></img>
    {{ end }}
		<h2 class="p-name post-title"><a href="{{ .URL }}">{{ .Title }}</a></h2>
	</header>
	<section class="e-content post-content">
		<a href="{{ .Permalink }}" class="u-url read-more"><span class="dt-published" datetime="{{ .Date.Format "2006-01-02T15:04:05-0700" }}">{{ .Date.Format "03:04 PM" }} ▸</span></a>
      {{ .Content }}
          {{ if .Truncated }}
              <p><a href="{{ .RelPermalink }}">Read More</a></p>
          {{ end }}
	</section>
	<footer class="post-meta">
	</footer>
</article>

```

I added the code below after` {{ .Content }}`. As you predicted, the truncate code below doesn’t work. It does work when I use `{{ .Summary }}` but that also “summarizes” all posts regardless of `<!--more-->`

```auto
{{ if .Truncated }}
              <p><a href="{{ .RelPermalink }}">Read More</a></p>
          {{ end }}

```

The `/layouts/post/summary.html` does have `{{ .Content }}` as the body so I’m not sure how Summary is being determined.

---

<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:** [January 28, 2022, 7:23pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/4 "2022-01-28T19:23:22Z")

</div>

Your problem statement and desired outcome are difficult to understand. Can you provide a link to the public repository for your project? It would save some time…

Also, you reference “/layouts/post/summary.html” but that isn’t called anywhere in your example.

---

<div class="post-metadata">

**Author:** ![Prat](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Prat](https://discourse.gohugo.io/u/Prat)\
**Post date:** [January 28, 2022, 7:25pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/5 "2022-01-28T19:25:15Z")

</div>

[Here you go](https://github.com/am1t/musings). New to Hugo so still figuring out stuff.

---

<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:** [January 28, 2022, 7:35pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/6 "2022-01-28T19:35:46Z")

</div>

When providing a repository for others to clone and build, please create a complete site (valid configuration, sample content, it builds, etc.). Thanks.

EDIT: I expect the following to work:

```auto
git clone --recurse-submodules https://github.com/am1t/musings
cd musings
hugo server

```

---

<div class="post-metadata">

**Author:** ![Prat](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Prat](https://discourse.gohugo.io/u/Prat)\
**Post date:** [January 28, 2022, 7:37pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/7 "2022-01-28T19:37:49Z")

</div>

Ok. But that’s not my repository. I’m just using the theme.

---

<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:** [January 28, 2022, 7:39pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/8 "2022-01-28T19:39:28Z")

</div>

The expectation is a site that we can build, not just a piece of it.

See [https://discourse.gohugo.io/t/requesting-help/9132](https://discourse.gohugo.io/t/requesting-help/9132).

> Let us see your code
> 
> Include a **link to the source code repository** of your project, because we really need the _context_ of seeing your templates and partials to be able to help you. It is trivial to do a quick `git clone` on your repo, then run `hugo server` in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
> 
> If you can’t share your repository for whatever reason, consider creating a dummy repo that you _can_ share, which reproduces the problem you’re experiencing.

---

<div class="post-metadata">

**Author:** ![Prat](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Prat](https://discourse.gohugo.io/u/Prat)\
**Post date:** [January 28, 2022, 7:43pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/9 "2022-01-28T19:43:12Z")

</div>

> [@jmooring](#):
>
> Your problem statement and desired outcome are difficult to understand.

Ok. Let me restate my problem and desired outcome. I’m looking to feature full-length posts on my homepage but for some posts, I want them truncated at the point when I specify the tag.

---

<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:** [January 28, 2022, 11:15pm UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/10 "2022-01-28T23:15:29Z")

</div>

#### Method 1

This approach essentially disables automatic summary splitting on your site. In your site configuration:

```auto
summaryLength = 999999 # Tolstoy's War and Peace has around 600000 words.

```

Then in your template you can do:

```auto
{{ .Summary }}

```

This will return a _stripped_ version of `.Content` unless you (a) manually split the summary with the `<!--more-->` tag, or (b) define the summary in front matter.

#### Method 2 (recommended)

Parse the raw content for the `<!--more-->` tag.

```auto
{{ if or (findRE `<!--more-->` .RawContent) .Params.Summary }}
  {{ .Summary }}
{{ else }}
  {{ .Content }}
{{ end }}

```

This will return `.Content` unless you (a) manually split the summary with the `<!--more-->` tag, or (b) define the summary in front matter.

---

<div class="post-metadata">

**Author:** ![Prat](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Prat](https://discourse.gohugo.io/u/Prat)\
**Post date:** [January 29, 2022, 12:18am UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/11 "2022-01-29T00:18:44Z")

</div>

Much appreciated. The second method worked!

I’ll figure out where to add the `summaryLength = 999999` for the first method.

---

<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:** [January 29, 2022, 12:23am UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/12 "2022-01-29T00:23:57Z")

</div>

Actually, don’t use Method 1. I forgot about [this issue](https://github.com/gohugoio/hugo/issues/8910#issuecomment-903158600). Tags are stripped.

---

<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:** [January 31, 2022, 12:24am UTC](https://discourse.gohugo.io/t/summary-on-home-page/36828/13 "2022-01-31T00:24:04Z")

</div>

Closed on January 31, 2022, 12:24am UTC

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