Updating a really old Ghost theme to 5.0 so custom templates and comments work
web design post

Updating a really old Ghost theme to 5.0 so custom templates and comments work

Dabitch
Dabitch

Ghost is now released in 5.0 and I was using an ancient theme that didn't have all the bells and whistles available. Ghost has video now, and comments too!

Some days my ADHD meds don't seem to take, as I managed to ask a question while linking the actual answer in the Ghosts forum. Awkward. Let's not link that and pretend it didn't happen. Epic brainfart.

Anyway, ages ago in my modified Ghost theme, I created custom template pages that looked different, that I could select while creating a page post. These pages were created with the old system, so they were named things like page-tags.hbs and selected when creating an "all tags" page.

But as I updated Ghost and didn't check my theme, that little feature suddenly disappeared. Now editing those special pages showed me no options at all. Like this.

There's supposed to be a drop-down menu there so that you can select what style you want.

Well, as it turns out, Ghost has changed what these pages should be called. "page-whatever.hbs" is not going to work, so you'll need to recreate those fancy pages but named them "custom-whatever.hbs", and only then will Ghost recognize that you have custom template .hbs files. If you go to create a new page now, the drop-down will work just fine. If you go to edit your previously made custom template pages you'll find that these are stuck in their old ways as the template announces "post URL matches page-whatever". It don't matter, if it ain't broke don't fix it. But if you want to track it down, this is because I did it the old school way, where my shortcut to tags was added in routes.

There are however other things broken with old themes that won't show off the new features of Ghost 5.0 - so these will need to be fixed.

The best way to check what you need to update in Ghost is to use gscan.ghost.org
Simply upload your theme.zip there and find what you need to change. It's lots of smaller simpler things, like replace {{@labs.members}} with {{@site.members_enabled}} and replace {{@site.lang}} with {{@site.locale}}

Once you've done that you'll need to add the new features, where we get the subscribers/members to sign up and the possibility to comment if you are a member.

These are things likely missing from your theme if you haven't updated it in a while. Add them to where it's most appropriate in your .hbs pages. In my case, it was all added to post.hbs.

        {{#if @labs.subscribers }}
          {{> subscribe-form }}
        {{/if}}
 {{#if comments}}
{{comments}}
{{/if}}


  {{#if @site.members_enabled}}
      {{#unless @member}}
      {{#unless @site.comments_enabled}}
      {{#if access}}

                  {{#if @custom.email_signup_text}}
                  {{@custom.email_signup_text}}
                   
                 {{/if}}
                 
      {{/if}}
      {{/unless}}
      {{/unless}}
      {{/if}}

Once you have this all enabled and set, you can see the subscribe button, the comment box, etc. See below how it looks when asking us to "subscribe" versus when I'm logged in.

My theme is a modified version of an old theme from Aspire Themes.