I am trying to add the most recent post to _index.md. When I put in the code on the home page it only shows it at the bottom of the page. If it does show it where I want to go then there will be dupilcation at the bottom of the page. The shortcode is
{{ range .Site.RegularPages.ByDate | first 5 }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{end}}
And in my _index.md I have
# Posts
{{< post >}}
# My and Other Projects
[Github](https://github.com/Luharion)
[đź”’Cyberscecurity blog](https://rebootcyber.xyz)
The .ByDate method sorts in ascending order: the first one will have the earliest date.
Chain the .Reverse method to get a descending sort.
{{ range .Site.RegularPages.ByDate.Reverse | first 5 }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{end}}
Regarding the “duplication on the page”, it sounds like your list template already iterates over a page collection, and then you are adding another via your shortcode. But without seeing your repository I’m just guessing.
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.
I copy the shortcode you send me and put it in layout/shortcodes/link.html. Then put
{{< link >}} in my _index.md. When I did that it still showed duplicates on the page