List All Categories on the Home Page

If you would like to list each category on your home page this can be done very easily with the code below.

One important note about this code is that it will not list sub-categories, you’ll  have to write a few extra lines of Chalk to get the sub-categories.

#set($allCategories = $data.Categories())

#foreach($category in $allCategories)
$category.Name :: $category.Body
#end
If some of your categories do not have a Body you will want to use $!category.Body to keep “category.Body” from printing on the page.  Additionally, to include this on the home page and no other page, this code needs to be added to your index.view file.

Leave a Reply

Your email address will not be published. Required fields are marked *