Custom Post Types are available in basalt-ng 0.2.0+
Custom Post Types allow you to specify for a post to be handled differently compared to ordinary posts. You can elect to have basalt generate an entirely separate archive page for them (or not), and the theme can respond to this, possibly rendering different archive or post display pages.
Custom Post Types must be defined in site.json to be used. Once defined, a post can be assigned to a different post type using the TYPE property in the post options.
Custom Post Types can be used in conjunction with the META post option to create advanced features on your basalt-ng website.
Each custom post type object in the site.json file has three properties.
The “name” property is the internal name given to the custom post type. It is used in the TYPE property in the post options to specify that a post is using that post type.
The “generate_archive” property tells basalt whether or not to generate an archive page for the custom post type, like the post list that exists for normal posts.
The “archive_name” property is used for the friendly, human readable name for the archive page.
"custom_post_types": [
{
"name": "recipe",
"generate_archive": true,
"archive_name": "Recipes"
}
]
To make use of custom post types for advanced features, a theme can use the “ssg_post_type” variable to determine if a custom post type is in use, and then using, for example, information stored in the post meta, render a different template that is more useful for the kind of information being displayed.
Lets say you want to store cooking recipes on your website. All recipes you store may have several things in common, lets say they all have: time to cook, a picture of the result, servings count and a flag saying if it's vegan or not.
Instead of writing all this information out again and again for each recipe, and putting them all as posts, you could use custom post types.
You would create a custom post type in your site configuration for recipes and enable archive generation, then, for each of your recipes you create a post with the TYPE set to “recipe”. Next, you create a meta object on all of those posts with the common information to all of the recipes.
Now, in your theme, you add extra logic to post list generation, checking the post type, and if it's recipe, then you display a grid with the image, cooking time from the meta and the name from the post information.
Finally, in your theme's post page generation , you would check if it's a recipe, then include an extra template which displays the image and other meta information in a standard layout.
Because they use a different archive page, these recipes don't clutter up your main posts list, and they have a more useful layout to the information they contain.