Templates and layouts

Create a part of your site with its own URL

A collection is a list of posts at its own address, such as /projects/ for a portfolio or /news/ beside your blog. Writers put a post into it in Ghost with an internal tag, such as #project, a tag whose name starts with # and that visitors never see. The collection has its own template for the list.

Add the collection

  1. Open your project in Fantasma.
  2. In the left sidebar, click + next to Templates. The Add Template menu opens.
  3. Under Recommended collections, click Projects, Courses, Writings or News. The collection appears under Collections in the list and opens on the canvas.

Each recommended collection comes with a Post template for its internal tag, listed under Post, so the posts in it get their own design too. Give posts with a tag their own design explains these templates.

Collection Address Internal tag
Projects /projects/ #project
Courses /courses/ #course
Writings /writings/ #writing
News /news/ #news

The new collection starts with a heading and a grid of its posts. A project holds up to 16 collections.

Add a collection with another name

  1. In the Add Template menu, under Variants, click Collection. A small dialog opens.
  2. In Custom collection, enter a name, such as resources. The name becomes the address, /resources/, and the internal tag, #resources, in small letters with hyphens for spaces.
  3. Optional. Turn on Create matching post template to add a Post template for that tag. The switch shows once you type a name.
  4. Click the arrow button at the end of the field.

Set the addresses

Select the collection in the list. The right sidebar holds its settings.

The right sidebar of the Projects collection, with Path projects, Post permalink /{slug}/ and Internal tag project
Setting What it does
Path The address of the list, such as projects for /projects/. Its first part cannot be members, ghost, p or email, which Ghost uses, and no two collections share a path.
Post permalink The address of each post in the collection. The default /{slug}/ keeps posts at the top level, such as /my-first-project/. Enter /projects/{slug}/ to put them under the collection's address. It must hold {slug} once, and takes no other part, such as a date. A change moves every post in it to a new address, so links shared before stop working unless you set up redirects.
Internal tag The tag, without #, that puts a post into the collection. Each collection needs its own tag.

Put posts into it in Ghost

  1. In Ghost Admin, open the post.
  2. Open the post settings.
  3. In the Tags field, enter the collection's internal tag, such as #project.
  4. Save or update the post in Ghost.

A post with the tag moves out of your main post list, the one at / and /page/2/, and into the collection. Give each post one collection tag.

Make the address work in Ghost

Ghost reads its addresses from a routes file, routes.yaml. A new collection, and every change to Path or Post permalink, needs the new file in Ghost, or the address shows an error page. Upload routes.yaml explains when Fantasma uploads it for you and how to upload it yourself. The collection's design reaches Ghost with your theme, when you publish your theme or upload it again.

To link to the collection from your header, add its address to your Ghost navigation, as Set up your site menu describes.

To remove a collection, select it and click Delete template at the bottom of the right sidebar. With the next routes file, its posts go back to your main post list.

Was this article helpful?