Showing latest post in a special template
I finally realized you can create a /content/latest.md
post WITH ONLY FRONT MATTER. This was a huge revelation. And in that front matter, you can designate a special layout. So my /content/latest.md
is just:
+++
layout = "latest"
+++
And in my /layouts/_default/latest.html
, something like:
<HTML>
<head>
{{- range first 1 .Site.Pages }}
<title>{{ .Title }}</title>
</head>
<body>
<h1><singleline>{{ .Title }}</singleline></h1>
{{ .Content }}
</body>
{{- end }}
</html>
The insight was being able to make an empty content file to serve as a placeholder on the server, and then filling it in dynamically via /layouts
, independent of the content file