There are a total of 81 posts here. | 這裡總共有 81 篇貼文。

ttheng's microblog. | 侃侃而隨想極短文。

How I made the homepage here a feed of all posts in full text

After installing the hugo-bearblog theme, I overwrote the index.html file in the theme layout by creating a new index.html file in the layouts folder of my main Hugo site directory that contains the following code, which is adapted from single.html from the layouts/_default folder from the original theme repository.

{{ define "main" }}
{{ $posts := where .Site.RegularPages "Section" "blog" }}
{{ range $posts }}
{{ if eq .Type "blog" }}{{ if not .Params.menu }}
<h1><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h1>
<p>
  <i>
    <time datetime='{{ .Date.Format "2006-01-02" }}'>
      {{ .Date.Format (default "02 Jan, 2006" .Site.Params.dateFormat) }}
    </time>
  </i>
</p>
{{ end }}{{ end }}
<content>
  {{ .Content }}
</content>
<p>
  {{ range (.GetTerms "tags") }}
  <a href="{{ .Permalink }}">#{{ .LinkTitle }}</a>
  {{ end }}
</p>
 <br>
 <hr class="solid">
 <br>
{{ end }}
{{ end }}

Some modifications on the CSS were also made to create the solid divider lines.

A side effect of this implementation is that all post images must be placed in the static folder1, which may increase site loading time. To mitigate this, I may need to paginate this feed. Will update on this in a future post, if possible.


2025-10-15 update: I have done the pagination. See this update post for more info.


  1. 2025-10-13 update: Actually the images can also be put in the same directory as the Markdown files of the posts (i.e. blog), but when including the images, the absolute path of the files may need to be specified. ↩︎

<< Previous Post

|

Next Post >>