Take a look at my public theme and plugin repositories (I spent the last two weeks breaking my theme code into plugins). The trick to controlling page content is the content
root level directory. The markdown files in this directory get to contain front matter followed by markdown content. My quest to control category pages led me to discover that for categories there is a default file deal where you can create a file at content/categories/category-name/_index.md
. I have a file in my theme at content/categories/inside-the-art/_index.md
that looks like this:
---
title: "Inside the Art"
description: "Guided tours through some of the signed art."
aliases: [/inside-the-art/]
menu:
main:
name: "Inside the Art"
title: "Inside the Art"
identifier: "inside"
url: "/categories/inside-the-art/"
weight: 106
---
*Guided tours through some of the signed art.*
Some interesting things can be accomplished with the front matter. The markdown portion becomes available to templates as .Content
. The category pages go through layouts/_default/taxonomy.html
, so I created a file that looks like this (it grabs the content as an introductory paragraph):
{{- /* Template for category pages */}}
{{- define "stylesheets" }}
<link rel="stylesheet" href="/assets/css/dark-nav.css">
<link rel="stylesheet" href="/assets/css/list.css">
{{- end }}
{{- define "main" }}
<section id="wrapper">
{{- /* Display any content provided for the category */}}
<div class="category-content">{{ .Content }}</div>
{{- /* Generate the pinned/remaining collections. */}}
{{- $pinned := .Site.Taxonomies.categories.Get "pinned" }}
{{- $all_pinned_pages := $pinned.Pages }}
{{- $pages := where .Data.Pages.ByDate.Reverse "Type" "post" }}
{{- $pinned_pages := $all_pinned_pages | intersect $pages }}
{{- $remaining_pages := $pages | symdiff $pinned_pages }}
{{- $pages_dict := dict "pinned" $pinned_pages "remaining" $remaining_pages }}
{{- /* Display the list of posts. */}}
<ul id="post-list">
{{- /* Handle pagination. */}}
{{- if .Site.Params.paginate_categories }}
{{- $paginator := .Paginate $remaining_pages }}
{{- if not $paginator.HasPrev }}
{{- range $pinned_pages }}
{{- partial "truncated-post-item.html" . }}
{{- end }}
{{- end }}
{{- range $paginator.Pages }}
{{- partial "truncated-post-item.html" . }}
{{- end }}
{{- else }}
{{- range $pinned_pages }}
{{- partial "truncated-post-item.html" . }}
{{- end }}
{{- range $remaining_pages }}
{{- partial "truncated-post-item.html" . }}
{{- end }}
{{- end }}
</ul>
{{- if .Site.Params.paginate_categories }}
{{ partial "pagination" . }}
{{- end }}
</section>
{{- end }}
The end result: On the Mind of Moondeer - Inside the Art
You can create entirely independent pages by sticking the markdown file directly under content
. I have a file at content/about.md
that looks like this:
---
title: "About"
description: "Just a touch of the biographical."
type: about
menu:
main:
name: "About"
title: "About"
identifier: "about"
url: "/about/"
weight: 120
---
Setting the type
value to about
causes Hugo to look for a template located at layouts/about/single.html
. Mine looks like this:
{{- /* Template for the about page */}}
{{- define "stylesheets" }}
<link rel="stylesheet" href="/assets/css/dark-nav.css">
<link rel="stylesheet" href="/assets/css/about.css">
{{- end }}
{{- define "main" }}
<section id="wrapper">
{{- partial "profile.html" . }}
<div id="wrapper"><p>
What? Y’all want something not constructed as a Trumpian dig for an itty bitty Twitter bio box?</p>
<p>
<img src="https://moondeer.blog/uploads/2021/f5130a1cf3.jpg" /></p>
<p>
Fine. Let me think on it (and yes, my father had to remind me that I was born at Northside and not Grady).
</p>
<p>I suppose the very least I could do is point you at sh$t I have already composed that just might elucidate some of my what-the-f$&kedness.</p>
<p>Take, for example, the conundrum of how one collects two undergraduate degrees and manages to go absolutely nowhere in life. Reading something like <a href="https://moondeer.blog/2021/02/21/on-fking-up.html">this</a> would probably go a long way with regard to cracking that particular nut.</p>
<p>Farther back, huh? Figuring childhood trauma, I presume. Not even a little bit. Life was a g@dd@mn cakewalk. </p>
<p><img src="https://moondeer.blog/uploads/2021/649b8f887e.jpg" width="3024" height="4032" alt="" /></p>
<p>Soccer all-star from age four, stuck into an accelerated learning program when I was in third grade after the score I put up on my Iowa Test of Basic Knowledge (within which the sneaky buggers hide an IQ test), and making friends was effortless. For f$&k’s sake, they decided to give me a senior superlative on account of my appearance.</p>
<p><img src="https://moondeer.blog/uploads/2021/e26af155c2.jpg" width="4032" height="3024" alt="" /></p>
<p>What went wrong? Well it turns out that socially isolating myself for 18 years was a bad f$&king idea (the jury is still out as to whether attempting to reconnect <a href="https://moondeer.blog/2021/02/27/so-long-twitter.html">via social media</a> was an equally bad idea).</p>
<p>Living in social isolation certainly makes <a href="https://moondeer.blog/2021/03/02/on-pet-loss.html">pet loss</a> more difficult. I have noticed; however, that there are a few perks to life on the other side of an existential crisis (I am headed into existential crisis numero deus so Imma keep those perks to myself for the time being).</p>
<p>There was a week not long ago where I truly thought I might be able to make the kinds of connections I have been searching for since jumping into social media last year. After 20 years, I remembered I was meant to write … and to have <a href="https://moondeer.blog/2021/02/24/on-dragons.html">big ideas</a>. The problem seems to be the having of the ideas in isolation. </p>
<p>The frustration of being unable to connect keeps a fire lit in the corner of my mind … tended by that piece of me wanting to say f$&k it … let’s just disappear … into the wild</p>
<p><img src="https://moondeer.blog/uploads/2021/93f6402abd.jpg" /></p>
<p>So there’s a rough sketch for ya. No doubt I will comeback later and overhaul the f$&k out of this little sh$t show.</p>
</div>
</section>
{{- end }}
The end result: On the Mind of Moondeer - About
I use the same pattern to create new pages in plugin-category-cloud, plugin-bookshelves, and plugin-gallery