Skip to content

Instantly share code, notes, and snippets.

@MattSLangford
Created January 17, 2020 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattSLangford/9cbc0bda4d87c4d9fff5e2865c032b2f to your computer and use it in GitHub Desktop.
Save MattSLangford/9cbc0bda4d87c4d9fff5e2865c032b2f to your computer and use it in GitHub Desktop.
Categories in Marfa
// STEP ONE: Create a template file called layouts/partials/post-categories.html with the following code:
{{ if .Params.categories }}
<section class="post-categories">
<p>{{ range sort .Params.categories }}<a href="{{ "/categories/" }}{{ . | urlize }}">{{ . }}</a> {{ end }}</p>
</section>
{{ end }}
// STEP TWO: Line to insert on posts and home page:
{{ partial "post-categories.html" . }}
// Refer to this post for more in depth instructions, including how to style: https://www.mattlangford.net/2020/01/14/adding-categories-to.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment