Show a static page for logged out members

I am creating a landing page for the newsletter portion of my new site. I want logged out members to see the landing page, and logged in/subscribed members to see a complete archive of all past issues. I know how to do this within the same template using {{#if member}}, but I would love to be able to create and maintain the landing page with the Ghost editor.

I tried creating a custom-newsletter.hbs page template that I can select in the Ghost editor, but I cannot figure out how to route that page to my newsletters collection in routes.yaml. I tried this:

collections:
  /newsletter/:
    permalink: /newsletter/{slug}/
    template: custom-newsletter
    filter: tag:newsletter

The routing seems to work, but I can’t get any context in the template β€” {{#post}} for example β€” to return data or even render HTML.

Am I wasting my time, or is there a practical way to do this?

It would seem writing this post helped me discover the solution! Setting the data property for my collection did the trick. My routes.yaml now looks like this:

collections:
  /newsletter/:
    permalink: /newsletter/{slug}/
    template: custom-newsletter-landing-page
    filter: tag:newsletter
    data: page.newsletter

With that in place, I was able to use the {{#page}} context in my template to pull the content for my landing page when members are logged out. Brilliant!

1 Like