Bookmark shortcode migration from Hugo 0.117 to 0.140

That’s my shortcode to display link to another blog post inside the post:

{{< bookmark url="/..............." description="............" >}}

shortcodes/bookmark.html:

{{ $path := .Get "url" }}
{{ $psummary := .Get "description" }}
{{- with .Site.GetPage $path }}
<figure class="fg-bookmark"><a href="{{ .RelPermalink }}" class="bkm"><div class="fg-bookmark-content"><div class="fg-bookmark-title">{{ .Title }}</div><div class="fg-bookmark-description">{{ $psummary }}</div><div class="fg-bookmark-website"><img src="/icons/favicon/favicon-16x16.png" class="fg-bookmark-icon" width="16px" height="16px" alt="logo"><span class="fg-bookmark-sitename">{{ site.Title }}</span></div></div>
    <div class="fg-bookmark-thumbnail">
      {{- if .Params.image }}
      {{ partial "imgoptim.html" . }}
      {{ end }}
    </div></a>
</figure>
{{ end }}

It worked in Hugo 0.117, but in Hugo 0.140 it is not rendered, no error. What to change?

You and I have had this conversation before, although it has been one-sided:

You are more likely to receive a prompt and accurate response if you post a link to your project’s Git repository.

See Requesting Help.

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.

1 Like

Checked. This code is not adapted to Hugo 0.140. Without this all shortcode is rendered.

Debug command not showing anything wrong. Is there any way to debug what’s wrong with the code as no errors are displayed?

Why are you ignoring the simple request to share a link to your repository? It is not possible to help you when only seeing three lines of code out of context.

1 Like

I am not able to show repo. but if you know where to look at exactly, then feel free to share the tips.

I have found problem.

{{< bookmark url="/..............." description="............" >}}

when url starts with slash / then shortcode is not rendered. When I remove slash at the beginning then shortcode works fine.

Is it a Hugo bug?

Am I forced to remove all slash symbol from the url setting or the bug will be fixed shortly?

P.S. my slug settings in config file:

permalinks:
  staticpages: /:slug
  posts: /:slug
  tags: /topic/:slug

sound more like a bug in your config,
shortcode call or just a migration issue.

you pass an absolute url and try to get that page. supposedly it’s not there.

already suggested: code defensive and use an else clause with the with statement. print out the values, check if the paths are correct…

check your configs permalinks etc. read the recent doks on the features you use in your setup and implementation.
117 is quite ancient nd you have mixed code in your sources now…

already stated: guessing around does not make sense (ok one guess baseURL changed to a subfolder)

if you can’t share your repo just create a small reproducible exmple with all involved components.