Those three issues could be fixed by moving the project’s partial into a shortcode.
layouts/shortcodes/projects.html
{{ range site.Data.projects }}
## {{ printf "[%s](%s)" .name .url }}
{{ .description }}
{{ end }}
content/projects/index.md
{{% projects %}}
Please note that use % instead of < to render the content in Markdown fully. The headings handled by markdownify method will not be included into the TableOfContents.
{{ range $project := $.Site.Data.projects }}
{{ printf "## [%s](%s)" $project.name $project.url | emojify }}
{{ $project.description }}
{{ if $project.image }}
{{ printf "" $project.image $project.name | emojify }}
{{ end }}
{{ if $project.pros }}
{{ printf "%s" "### Pros :smile:" | emojify }}
{{ range $pros := $project.pros }}
- {{ $pros }}
{{ end }}
{{ end }}
{{ if $project.cons }}
{{ printf "%s" "### Cons :disappointed:" | emojify }}
{{ range $cons := $project.cons }}
- {{ $cons }}
{{ end }}
{{ end }}
{{ end }}
and my project page:
---
title: "Similar projects"
date: 2023-03-24T09:12:35+10:00
draft: false
---
# Introduction
There are several projects listed down below.
## List
> :warning: Note: projects are compared to this one.
{{% project_list %}}
There is just one issue left: images are not rendered now. I wonder to know why.
Thanks. Hmm… It seems that I can’t reuse {{< image src="git-man.jpg" alt="git man" position="center" style="border-radius: 4px;" >}} in the shortcode. To check whether HTML can be used I’ve typed <h1>bla bla bla</h1> and such headers got discarded after rendering. Is it expected? And how to make image corners rounded in a shortcode which is called with percent signs? Or I have to change theme CSS to do it?
As I know, it’s not allowed that use a shortcode inside the shortcode template, but nested shortcode is valid, see Shortcode templates for details.
A workaround is that create an image partial, and invoke it inside shortcode template. You can reuse the image partial on the image shortcode.
You can also output the raw HTML, see below.
I guess the RAW HTML was omitted, you can turn it off.