Truncating posts

I’m trying to set up truncated posts on the Alpine theme and having no luck.

I followed the instructions here to create a custom theme and activated it.

I then navigated to “Edit Custom Themes” and opened layouts/_default/list.html.

The instructions say to look for this code:

  <div class="e-content">
    {{ .Content }}

But the only code I see in list.html is this:

{{ define "main" }}
  {{ partial "post-list.html" . }}
{{ end }}

Am I looking in the wrong place?


I think I solved the problem. I switched back to the Tiny theme.

And installed the Summary Posts plugin.

You’ve have to look for the .Content in the post-list.html file.

1 Like

A partial is a way of including another file in your file. In this case, the Alpine theme pulled out the {{ .Content }} part and handles that in layouts/partials/post-list.html. So edits that change what is displayed are based on that file.

This is part of why folks who want big changes to how content display I think get tripped up-- themes do not have to follow remotely the same structure, so any notion of editing these core pages and how they display things are necessarily theme-specific in most cases. That means, for example, in a lot of cases supporting things like excerpts/truncate/summary has to be on a per-theme basis-- because the underlying theme needs to directly edited in a way that is not as simple as “include this on top of my theme” which is how most plug ins work.

MB official themes sometimes all get updated at once to follow a similar enough structure to help with this for certain features (like paginate), but customized themes or even MB themes that are super complex Hugo built for it’s own thing (that people like a lot) can be difficult to modify the right way.

That’s why Tiny is a very complex theme that keeps just directly building in these features versus writing a plug in etc. Themes are deeply powerful, and if you want a lot of control over your content, I don’t think there’s anyway around learning Hugo theming. IMO, this is for the better. It’s also not really that different from most blogging systems.

1 Like