I run my Ghost installation via Bitnami on AWS. Here are some common things I've needed to resolve.


Creating a Simple "Recent Posts" Loop

The handlebars code that Ghost runs on isn't that complicated. All of the logic for the recent posts loop is handled in the {{get}} logic, documented here. Here's the skeleton of the code I used to build the recent posts loop:

{{#get "posts" limit="5" include="tags" order="published_at desc"}}
  {{#foreach posts}}
    <p><a href="{{url}}">{{title}}</a> | {{date}}, {{tags separator=", "}}</p>
  {{/foreach}}
{{/get}}

url,  title, and date are automatically pulled in but you need to manually include author and tags if you want to show those. published_at and date both show you the published date, but the former is a full timestamp use for sort order while the latter is the reader-friendly version.

Wrap that up in some CSS to make it look pretty and then add it to the index.hbs file. Here's my final version:

<!-- Recent Posts -->
  <div style="background-color: #f7f7f7;padding: 40px 50px 20px 50px;margin-bottom: 50px;">
    <h3 style="padding-bottom: 20px; border-bottom: 1px solid #ccc;margin-bottom: 20px;">Recent Posts</h3>
  {{#get "posts" limit="5" include="tags" order="published_at desc"}}
      {{#foreach posts}}
      <p><a href="{{url}}">{{title}}</a> <span style="font-size: 0.8em !important; opacity:0.5;">{{date}} | <span style="padding: 3px 7px; border-radius: 3px; border: 1px solid #e0e0e0;">{{tags separator=", "}}</span></span></p>
      {{/foreach}}
  {{/get}}
  </div>
<!-- End Recent Posts -->

Creating a Pages loop was similar. Just replace posts with pages in the appropriate area.

Lastly, it took a bit of sleuthing to figure out how to exclude content. This was done via adding a - before the thing you're filtering. For example:

{{#get “tags” filter=“slug:-about”}}

Getting HTTPS Working Properly

To get HTTPS on your site, you need to follow two steps. First, you need to set up your SSL certificate. If you're using Bitnami, it's very straightforward. As per their documentation, you just need to run their HTTPS Configuration Tool:

Execute the following command and follow the prompts:

sudo /opt/bitnami/bncert-tool

But going through this process only got me halfway there. I noticed that some .js calls were being made over HTTP, which caused CORS issues and generally stopped the membership features from working correctly. I tried setting up Apache Force HTTPS as per Bitnami's documentation and it didn't help.

The solution was the following, as per https://community.bitnami.com/t/how-to-get-https-working-80-redirect-loop-issues-resolved-ghost-gcp/55867/3:

There are two issues after setting up your SSL certificate. You'll notice your nav links have :80 appended to the end, and of course lack the S in https.

First part - Fix Ghost URL

Stop Ghost & open the Ghost config file:

sudo /opt/bitnami/ctlscript.sh stop
sudo vim /opt/bitnami/apps/ghost/htdocs/config.production.json

Edit the URL part to include the s after http. Remove the :80. Then, Enable Apache's protocol proxy pass.

sudo vim /opt/bitnami/apps/ghost/conf/httpd-app.conf

Add this to the top of the file:

RequestHeader set X-Forwarded-Proto "https"

Restart Ghost.

sudo /opt/bitnami/ctlscript.sh start

... and you're set.