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 }}
  </div>

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?

Thanks!

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

I use the Marfa theme which looks like it is „official“. Same problem here.

I cannot find the code sequence in post-list.html. After digging deeper i think I found it in post-item.html (one more layer deeper).

Is 3rd line the code I have to break up and change?

  </section>
  {{ else }}
	<div class="post-body e-content">{{ .Content }}</div>
  {{ end }}
  <a href="{{ .Permalink }}" class="u-url">

Thanks in advance

Thomas

Yes, Marfa’s official, and like all themes, works a little bit different. post-item is what you want, and what you’d want is {{ .Summary }} and not the full content.

Thanks for your reply.

Is there any way to test? I read about test blogs, and I found @manton’s post about the topic from 2019, but too much changed since then.

Or is the test blog not included in Premium?

Test blogs still exist and work.

I do not find the way to activate it.

I think you can just click the three dots next to your blog name and it’ll be there. This is from my design page.

CleanShot 2024-12-26 at 14.33.39@2x

Hi Jason,

Not here (also from my design page). I think this is the way to select the test-blog if it is existing.

As I wrote, I found an older post from 2019 with a description how to create the test-blog. But I cannot find this button.

In an article on the Posting API there is a similar description (Design → Edit Custom Themes → New Test Blog) which also doesn‘t work for me (I cannot find the button).

Regards

Thomas

The button should appear there if there isn’t already a test blog. If you’re not seeing it, can you try visiting micro.blog/new/test and see if that creates the test blog?

Hi Manton,

no, this generated an empty preview blog:

image

Regards

Thomas

Ahh… I finally understand. When we added the special preview blogs, internally they are kind of the same as a test blog, so it did break the test blog button.

Fixing it and the change should be live today. Thanks!

Update: Should be fixed now.

Yes, it‘s back.

Thanks

Thomas