Shortcode related post

original code

<ul>
  {{ range first 5 ( where ( where .Site.Pages.ByDate.Reverse ".Params.tags" "intersect" .Params.tags ) "Permalink" "!=" .Permalink ) }}
    <li class="relatedPost">
      <a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a><br />
      {{ .Description | markdownify }}
    </li>
  {{ end }}
</ul>

Shortcode

<ul>
  {{ range first 5 ( where ( where .Site.Pages.ByDate.Reverse ".Params (.Get 0)" "intersect" .Params (.Get 0 ) "Permalink" "!=" .Permalink ) }}
    <li class="relatedPost">
      <a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a><br />
      {{ .Description | markdownify }}
    </li>
  {{ end }}
</ul>

Single post
{{< related hugo >}}

always error. I’ve tried various ways still error.

how to fix it?

thank you

Not sure what your error is (you should add the error message to your post), but I suggest you have a look at this:

1 Like
ERROR 2017/09/25 00:04:25 Failed to add template "shortcodes/related.html" in path "/home/sondang/Documents/berita/layouts/shortcodes/related.html": template: shortcodes/related.html:2: unclosed left paren
ERROR 2017/09/25 00:04:25 shortcodes/related.html : template: shortcodes/related.html:2: unclosed left paren
Started building sites ...
ERROR 2017/09/25 00:04:25 Unable to locate template for shortcode "related" in page "post/10 distro terbaik 2017.md"

I am now using related content but I want to know how to fix my problem

thank you

sounds a lot like what I posted yesterday:

could also be that. You are missing one at the end I think.

i tried your code but your code is still error.

now I use related content given @bep and it’s better than related post from me.

You had a right parenthesis missing in the first line, this should be correct:

<ul>
  {{ range first 5 ( where ( where .Site.Pages.ByDate.Reverse ".Params (.Get 0)" "intersect" .Params (.Get 0 ) "Permalink" "!=" .Permalink )) }}
    <li class="relatedPost">
      <a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a><br />
      {{ .Description | markdownify }}
    </li>
  {{ end }}
</ul>

still an error but the problem before it is finished.

ERROR 2017/09/25 14:42:13 error processing shortcode "shortcodes / related.html" for page "post / archlinux-distro-terbaik.md": template: shortcodes / related.html: 3: 21: executing "shortcodes /related.html "at <where>: wrong number of args for where: want at least 2 got 1

config.toml

[taxonomies]
	kategori = "kategori"
	tag = "tag"

content post

+++
title = "Archlinux Distro Terbaik"
date = 2017-09-25T14:33:06+07:00
kategori = ["Linux"]
+++

{{< related kategori >}}

shortcodes/related.html

<ul>
  {{ range first 5 ( where ( where .Site.Pages.ByDate.Reverse ".Params (.Get 0)" "intersect" .Params (.Get 0 ) "Permalink" "!=" .Permalink )) }}
    <li class="relatedPost">
      <a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a><br />
      {{ .Description | markdownify }}
    </li>
  {{ end }}
</ul>