Search code examples
content-management-systemhandlebars.jsghost-blog

Ghost: Display Posts From Multiple Tags On One Page


I'm developing a website for a magazine using Ghost (http://ghost.org/) and would like to have pages that display posts from two related tags. Eg. "Science and Environment". I understand that when using a static page you do not have access to posts so I cannot for example do this. This would however be the ideal solution.

{{#foreach posts}}
    {{#has tag="science, environment"}}
        do thing
    {{\has}}
{{/foreach}}

I have had a look on the Trello roadmap (https://trello.com/b/EceUgtCL/ghost-roadmap) but couldn't spot anything there. I would appreciate any help on a workaround.

Cheers


Solution

  • This is possible but a bit tricky

    • You should install self-hosted Ghost . There is a lot of step-by-step manuals how to do this on Amazon, DigitalOcean, Heroku, etc.

    • You should create your own custom Handlebars helper for your purposes.

      1. Create myhelpers.js in the Ghost project root and put your own helper code here. For example: {{bytag}} helper which selects posts by one tag. You can extend this to query posts by more than one tag.

      2. At the beginning of config.js place require('./myhelpers')(); to activate your custom helper.

      3. Restart Ghost