Hi, I just came across a few threads (like List all posts but drafts or Keeping drafts out of the rss feed), I’m still fuzzy on how to actually make it happen.
I would like to build future and draft posts content, but not list them in the usual lists (tags, rss, posts), however I would like to list then in a specific path (e.g. host.tld/d/
). So I’d like to hide draft posts anywhere exept when explicitly asked.
- Currently I’m having difficulty to just create a list in a /d/ path, I have tried various combinations
-
content/d/_index.md
or without
+++
draft = true
title = "Drafts"
+++
-
layouts/d/index.html
or layouts/d/list.html
{{ define "header" }}
{{ partial "header.html" . }}
{{ end }}
{{ define "content" }}
{{ partial "drafts/content.html" . }}
{{ end }}
{{ define "footer" }}
{{ partial "page-list/footer.html" . }}
{{ end }}
<!-- https://gohugo.io/templates/lists/ -->
layouts/partials/drafts/content.html
<span class="section__title">{{ .Title }}</span>
<ul class="posts drafts">
{{ $paginator := .Paginate (where (where .Site.Pages "Type" "in" "posts") "Draft" true ) }}
{{ partial "pagination.html" . }}
<br/>
{{ range $paginator.Pages }}
<li>
<span class="list__title--small">
<time class="hidden-tablet">{{ .Date.Format (.Site.Params.dateformat | default "Jan 02 '06") }}</time>
<a href="{{ .RelPermalink }}" {{if .Draft}}class="draft"{{end}}>{{ .Title }}</a>
</span>
</li>
{{ end }}
</ul>
But of course the given setup is wrong, either the HTML is empty or the page only contains what’s _index.md but nothing else. Did I missed something in https://gohugo.io/templates/lists/.
But then even if it works I’ll probably have to go through every template to filter drafts right ?