Now, I want to provide like a menu to the subfolders topic1, topic2 from the writeups, but I also want to have an introduction in the writeups page too. I noticed that hugo automatically generated links to these subfolders but I was not able to add any extra content.
I am new to hugo and I need help.
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.
Great. That seemed to work! Could you explain what changed by using _index.md and how it automatically lists the subfolders?
Also do i need to do the same in order to list other pages? Not subfolders this time
Let me try to rephrase. The pico and tryhackme folders will contain multiple pages in the near future. I want their index.md to pose as a navigation page. The writeups will include taxonomies like difficulty/category/os. Is there a way to make index.md list these pages by thejr taxonomies?
Something like:
Category:
BinExp:
Crypto:
Forensics
If you want a directory to be a section (i.e., multiple pages) it either needs to be a top level directory, or it must contain an _index.md file (with an underscore).
A directory must not contain both an index.md file and an _index.md file.
So just like you did with the writeups directory, you’ll you need to rename some files:
Hey there! I spent some time reading and I came up with the following shortcode which seems to do exactly what I want! I did not expect it to be relatively easy to make.
Are there any improvements I can make whatsoever? Thanks in advance!
<!-- layouts/shortcodes/taxonomy-list.html -->
{{ $taxonomies := .Get "taxonomies" | default "" }}
{{ $taxonomyList := split $taxonomies "," }}
{{ if gt (len $taxonomyList) 0 }}
{{ range $taxonomyList }}
{{ $taxonomy := . }}
<h2>{{ $taxonomy | title }}</h2>
{{ range $term, $taxonomyPages := index $.Site.Taxonomies $taxonomy }}
<h3>{{ $term }}</h3>
<ul>
{{ range $taxonomyPages.Pages }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ else }}
{{ range $taxonomyName, $terms := $.Site.Taxonomies }}
<h2>{{ $taxonomyName | title }}</h2>
{{ range $term, $taxonomyPages := $terms }}
<h3>{{ $term }}</h3>
<ul>
{{ range $taxonomyPages.Pages }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ end }}
{{ end }}