Custom author.hbs

@andrianov as an aside, I want to add that your Forum Profile Picture . . .

Screenshot 2020-01-24 at 2.21.37 PM

. . . is absolutely adorable!

( . . . and it seems to accurately express your attitude toward this annoying problem . . . )

Thank you for the appreciation.
Iā€™m not giving up hope that the problem will be solved.

Seriously, I canā€™t understand why no one can explain how to make a proper copy of the template for the author? And why Ghost tells me itā€™s not right to use {{#author}} although it works correctly.

1 Like

Hi @andrianov Iā€™m having the exact same problem.

The frustrating thing is, I canā€™t upgrade Ghost to v5 because GScan fails during the upgrade :face_with_head_bandage:

We could potentially just make static pages/templates for each author, but thatā€™s not an elegant solution. I really want to use the Author object because it is nice being able to pull in data from author profiles.

Did you have any luck with this?

According to the Ghost docs on the post helper, it seems that {{#primary_author}} can only be used on a page or post that actually has an author. The author pages do not technically have authors, which would explain why we canā€™t access any of its properties.

The block expression {{#post}}{{/post}} isnā€™t strictly a ā€˜helperā€™. You can do this with any object in a template to access the nested attributes e.g. you can also use {{#primary_author}}{{/primary_author}} inside of the post block to get to the primary authorā€™s name and other attributes.

In my case my workaround was to revert back to using an author.hbs template and simply using the {{#author}} block to display the properties I need inside it.

I hope this helps anyone having the same issue.

I ended up here on this post far later than to be helpful to anyone above, but in case someone else with this issue happens by, I figured I should post the solution!

Basically I think itā€™s easy to read this (in Ghostā€™s README):

One neat trick is that you can also create custom one-off templates just by adding the slug of a page to a template file. For example:

- author-ali.hbs - Custom template for /author/ali/ archive

And think that all one needs to do is to duplicate author.hbs, rename it as e.g. author-ali.hbs, and expect everything to work. And it does work locally, until you try to upload it as a theme, where it gets rejected with this message about the {{#author}} block no longer being supported outside of author.hbs.

Apparently the {{#author}} block was restricted in this way when Ghost refactoring was done to allow for multiple post authors. And since author pages are specialā€”technically lacking an author (in the sense theyā€™re not a post)ā€”the theme activation error suggestions for replacing with {{primary_author}} or {{foreach authors}} will fail.

Hereā€™s the solution for dealing with a one-off author-based template (in this example, author-ali.hbs:

Replace:

{{author}}
ā€¦
{{/author}}

With (note: make sure to replace ali with your custom slug):

{{#get 'authors' filter='slug:ali'}}
{{#foreach authors}}
ā€¦
{{/foreach}}
{{/get}}

1 Like