Hugo

Interesting issues between hugo versions

I have encountered some rather interesting problems in differing Hugo versions. I am running Ubuntu 18.04 (Bionic Beaver). The apt version of Hugo is at 0.40.1, and the snap version is at 0.57.1. I have two sites, one using the Universal theme and the other using the Startbootstrap Clean Blog theme. When using 0.40.1, the Startbootstrap site builds fine. The Universal site fails to build, giving the error
ERROR 2019/08/16 10:08:24 Error while rendering "home" in "": template: index.html:26:11: executing "index.html" at <partial "recent_post...>: error calling partial: template: partials/recent_posts.html:12:54: executing "partials/recent_posts.html" at <markdownify>: wrong number of args for markdownify: want 1 got 0
When using version 0.57.1, both sites build fine, but with both the blog posts on the front page disappear and are replaced with a single item that looks like a post and just says “Blogs”. When clicked, it leads to the blog page. I generally use the snap extended version.

Interesting… Now post the content of partials/recent_posts.html and somebody will find the issue :slight_smile:

By the way, I wouldn’t worry if an older version Hugo version fails to build and a newer has no issues. I would say that these themes just updated according to the updates in Hugo itself. 0.40 sounds eerily old. Like 2 years ago which in Hugo years is like three to five generations. I had my first experiences with Hugo at 0.42. So if a theme fails and you have access to a newer version - relax, use the newer version, forget the older one.

I think there is a new mechanism in newer versions (see modules) that will enable Hugo themes to tell you which Hugo version they require at least. 0.40 - old. Very old.

I did find this which seems to be the same thing as my 0.57.1 issue. I know 0.40 is old, but it’s what’s in the 18.04 repositories, and like I said, I generally use the Snap version. I just tried installing the Apt version to see if it changed anything.
Here’s recent_posts.html:

{{ if isset .Site.Params "recent_posts" }}
{{ if .Site.Params.recent_posts.enable }}
<section class="bar background-white no-mb">
    <div class="container">

        <div class="col-md-12">
            <div class="heading text-center">
                <h2>{{ .Site.Params.recent_posts.title }}</h2>
            </div>

            <p class="lead">
              {{ .Site.Params.recent_posts.subtitle | markdownify }}
            </p>

            <!-- *** BLOG HOMEPAGE *** -->

            <div class="row">

                {{ $posts := .Paginate (where .Data.Pages "Type" "blog") }}
                {{ range first 4 $posts.Pages }}
                <div class="col-md-3 col-sm-6">
                    <div class="box-image-text blog">
                        <div class="top">
                            <div class="image" style="overflow:hidden">
                                {{ if isset .Params "banner" }}
                                <img src="{{ .Site.BaseURL}}{{ .Params.banner }}" class="img-responsive" alt="" >
                                {{ else }}
                                <img src="{{ .Site.BaseURL}}img/placeholder.png" class="img-responsive" alt="">
                                {{ end }}
                            </div>
                            <div class="bg"></div>
                            <div class="text">
                                <p class="buttons">
                                    <a href="{{ .Permalink }}" class="btn btn-template-transparent-primary"><i class="fa fa-link"></i> {{ i18n "readMore" }}</a>
                                </p>
                            </div>
                        </div>

                        <div class="content">
                            <h4><a href="{{ .Permalink }}">{{ .Title }}</a></h4>
                            <p class="author-category">
                            {{ with .Params.author }}
                            {{ i18n "authorBy" }} <a href="#">{{ . }}</a>
                            {{ end }}
                            {{ i18n "publishedOn" }} {{ .Date.Format .Site.Params.date_format }}
                            </p>
                            <p class="intro">{{ .Summary }}</p>
                            <p class="read-more">
                              <a href="{{ .Permalink }}" class="btn btn-template-main">{{ i18n "continueReading" }}</a>
                            </p>
                        </div>
                    </div>
                    <!-- /.box-image-text -->

                </div>
                {{ end }}

            </div>
            <!-- /.row -->

            <!-- *** BLOG HOMEPAGE END *** -->

        </div>
    </div>
    <!-- /.container -->
</section>
<!-- /.bar -->
{{ end }}
{{ end }}

You can find instructions about what’s wrong with the above over here:

@onedrawingperday Using that as a reference I managed to find and fix the problem with both themes. Thanks!

1 Like