Currently, pages and posts can only be categorised and indexed using these taxonomies:
authors
categories
tags
Therefore the only index pages generated are for authors, categories and tags.
Users should be able to define their own taxonomies, and therefore, index pages
Pages and posts are currently not really separate things...
They are not well defined enough - a post simply lives in posts/, and a page doesn't - but they both get the same taxonomies in their front matter: "author", "category" and "tags".
Pages don't get listed in index pages however (only posts), cos the code that generates the index pages only looks in posts.csv (before this PR).
In this PR however, the index page generation gets its data from the front matter of .mdsh files in posts/... So still (for now), only posts in index pages.
Current index pages (lists of posts) occupy root of site
Solution to last two points:
define proper page types:
posts have indexes pages in root of site
pages dont get listed on index pages
index pages of all other page types namspaced by page type:
/categories/blog.html <-- list posts
/events/categories/blog.html <-- lists events about blogs
We can work out the page type by checking the (soon to be created) page_type field in the front matter, and grabbing the relevant data.. This could be a YAML file called page_types.yml, containing:
(Note: product options like price should not get an index page, so still live in site.yml)
When users do new event or new product, we set $1 to page_type, check it exists in page_types, and if so, we grab the relevant taxonomy list, and generate the front matter as usual (wizard style, in the terminal).
About Taxonomies
Let’s assume you are making a website about movies. You may want to include the following taxonomies:
Actors
Directors
Studios
Genre
Year
Awards
You'd specify the values of these items in the front matter of each .mdsh file.
From these terms, Mdsh would automatically create index pages for each taxonomy - actors, directors, studios, genres, years, and awards - with each index page listing all of the Movies that matched that specific taxonomy.
Current taxonomy not defined anywhere, but is basically this:
taxonomies:
category: categories
tag: tags
How to
Custom taxonomies other than the defaults must be defined in your site config before they can be used throughout the site.
You need to provide both the plural and singular labels for each taxonomy.
taxonomies:
category: categories
+ series: series
tag: tags
Once a taxonomy is defined at the site level, any piece of content can be assigned to it
Assigning content to a taxonomy is done in the front matter. Simply create a variable with the plural name of the taxonomy and assign all terms you want to apply to the instance of the content type.
title: Some cool title
categories:
- Development
series:
- Go Web Dev
slug: hugo
tags:
- Development
- Blogging
If you need to add custom metadata to your taxonomy terms, create a page for that term at /assets/data/<TAXONOMY>/<TERM>/_index.md and add your metadata in it’s front matter.
Continuing with our ‘Actors’ example, let’s say you want to add a wikipedia page link to each actor. Your terms pages would be something like this:
The user should be asked to enter each item in the front matter, in the usual wizard-style way (fill out each field on the terminal).
The movie.md template could contain front matter which, when given the right data, would like so:
title: The Haunted House (2019)
slug: the-haunted-house-2019
release_date: 2019
publisher: Fox
director: Tony Bobsonsonon
actors:
- Mr. Foo man
- Mrs. Bar woman
---
Problem(s):
authors
categories
tags
Therefore the only index pages generated are for authors, categories and tags.
Users should be able to define their own taxonomies, and therefore, index pages
posts/
, and a page doesn't - but they both get the same taxonomies in their front matter: "author", "category" and "tags".posts.csv
(before this PR)..mdsh
files inposts/
... So still (for now), only posts in index pages.Solution to last two points:
We can work out the page type by checking the (soon to be created)
page_type
field in the front matter, and grabbing the relevant data.. This could be a YAML file calledpage_types.yml
, containing:(Note: product options like
price
should not get an index page, so still live insite.yml
)When users do
new event
ornew product
, we set $1 topage_type
, check it exists inpage_types
, and if so, we grab the relevant taxonomy list, and generate the front matter as usual (wizard style, in the terminal).About Taxonomies
Let’s assume you are making a website about movies. You may want to include the following taxonomies:
You'd specify the values of these items in the front matter of each
.mdsh
file.From these terms, Mdsh would automatically create index pages for each taxonomy -
actors
,directors
,studios
,genres
,years
, andawards
- with each index page listing all of theMovies
that matched that specific taxonomy.See: https://gohugo.io/content-management/taxonomies/
Current taxonomy not defined anywhere, but is basically this:
How to
Custom taxonomies other than the defaults must be defined in your site config before they can be used throughout the site.
You need to provide both the plural and singular labels for each taxonomy.
Once a taxonomy is defined at the site level, any piece of content can be assigned to it
Assigning content to a taxonomy is done in the front matter. Simply create a variable with the plural name of the taxonomy and assign all terms you want to apply to the instance of the content type.
If you need to add custom metadata to your taxonomy terms, create a page for that term at
/assets/data/<TAXONOMY>/<TERM>/_index.md
and add your metadata in it’s front matter.Continuing with our ‘Actors’ example, let’s say you want to add a wikipedia page link to each actor. Your terms pages would be something like this:
There are multiple ways to use taxonomies throughout your project templates:
About "Archetypes" (page types)
Archetypes are templates used when creating new content.
What are Archetypes?
Archetypes are markdown template files in the
.app/templates/markdown/
directory, that contain pre-configured front matter.^ where
$1
is the archetype name, and$2
the title of the new item to be created.The above would create a new content file in using the first archetype file found:
Users could also run something like this:
The user should be asked to enter each item in the front matter, in the usual wizard-style way (fill out each field on the terminal).
The
movie.md
template could contain front matter which, when given the right data, would like so: