Recipes

Enhance your members experience with these code snippets and customise your membership site to suit your needs.

We've put together a few recipes for some common use-cases of Members in Ghost, including how to create custom content collections on your site to display different types of content.

Configuring email newsletter content

It's possible to email new content directly to your members using the native email newsletter feature in Ghost. This makes it easy to automatically send new posts to subscribed members, or even use Ghost as an email newsletter platform.

Premium newsletters

Use-case: Run a premium newsletter for paying subscribers, but prevent email content from appearing on your site.

Using the following in your routes.yaml would prevent content that is set to paid-members only from rendering on your site - content that is public or members only would render as expected:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: visibility:-paid

Newsletter directory

Use-case: Send email newsletters to your entire members list create a custom directory where your newsletter issues are stored (example: Publisher Weekly).

Using the routes.yaml file, it's possible to automatically feature your email newsletter content on a unique directory. For example:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: visibility:public
  /newsletter/:
    permalink: /{slug}/
    template: index
    filter: visibility:-public

The visibility filter value can be public, members or paid and filters content based on post access level. In this example, the /newsletter/ directory will only contain posts that are set to members only.

For these configurations to work, you'll also need to add visibility="all" in any #foreach helpers in your theme.

Next steps

Dynamic routing in Ghost themes is extremely flexible and you can create just about any kind of site structure to suit your needs. For example, you could filter content even further using tags to differentiate between posts and emails, or you could create dynamic paginated content hubs. Read more about routing in our Handlebars documentation.