Closed Mati20187 closed 1 year ago
Note that all the pages with next/prev on Landchad share a common directory, basic/
. In the baseof.html
file for Landchad, there is an if statement {{- if in .Params.tags "basic" -}}
that only inputs the next/previous articles if it is tagged as a "basic" article. Same thing for the mail
tag, but this is clumsily written.
I don't have my websites code online, but I have something similar on my own website where you get the next/previous links only inside a post inside articles/
or updates/
, that looks like this:
{{ if or (eq .Section "articles" ) (eq .Section "updates" ) -}}
{{ if or .NextInSection .PrevInSection -}}
<div id="nextprev">
{{- with .PrevInSection }}
<a href="{{ .RelPermalink}}"><div id="prevart">Previous:<br>{{.Title}}</div></a>
{{ end -}}
{{- with .NextInSection -}}
<a href="{{ .RelPermalink}}"><div id="nextart">Next:<br>{{.Title}}</div></a>
{{ end -}}
</div>
<br clear=both>
{{ end -}}
{{ end -}}
Actually, using the Section
variable as I do here is probably better than the way Landchad is doing it since that requires you to tag the articles.
That should give you enough help to figure it out for your own usecase.
Hi, I've been trying to get the nextprev buttons to only appear in certain section like a blog. Currently they're appearing on all pages except the home page and are linking pages that have nothing in common (for example, I have a button redirecting from a blog post to a page with contact information because it was created after that blog entry). Is there an option to do that? I've noticed that on landchad.net the pages that belong to the same category (like the ones in "Start a Website" section) have the "next" button whereas websites that aren't connected (i.e. the ones in "Build your own platform!") don't have the next and previous navigation. However I haven't been able to figure out how to implement it on my website. I would really appreciate any help