Custom author.hbs

I copied the author.hbs template and called it author-and.hbs.

Instead of Twitter and Facebook, I decided to add other social networks.
In the end, the new template for the individual author works.

But when you activate a theme, you get the following error.

How to get rid of this error? What am I doing wrong?

1 Like

@andrianov - open your author-and.hbs file and look for all instances of {{#author}} in that file.

Replace all of them with {{#primary_author}} and then re-upload the theme and the error should go away.

You can also notice in the Docs page linked below that the correct usage is {{authors}} – with s on the end.

To output just the singular, first or only author, {{#primary_author}} is the correct usage.

1 Like

As soon as I replace {{#author}} with {{{#primary_author}}, I get an error.

The top part of the page stops showing up. So the header and the information about the author.

I use the standard casper theme

Could you please paste in the contents of your author-and.hbs file so I can see what you’ve got?

This is the code. It’s no different than author.hbs.
I just copied the file and didn’t change it.

I only changed {{#author}} to {{#primary_author}}.


{{!< default}}
{{!-- The tag above means - insert everything in this file into the {body} of the default.hbs template --}}

{{!-- Everything inside the #author tags pulls data from the author --}}

{{> site-header}} {{> header-background background=cover_image}} {{!--Special header-image.hbs partial to generate the background image--}}
{{#if profile_image}} {{name}} {{/if}}


{{#if bio}}


{{#if location}}
{{plural ../ empty='No posts' singular='% post' plural='% posts'}}
{{#if website}} ОГО {{/if}} {{#if twitter}} Twitter {{/if}} {{#if facebook}} Facebook {{/if}}

{{!-- The main content area --}}

    <div class="post-feed">
        {{#foreach posts}}

            {{!-- The tag below includes the markup for each post - partials/post-card.hbs --}}
            {{> "post-card"}}



Thank you. Please also paste in the contents of your default.hbs file. Also if you could share a link to the site, if it is live…

I’m using the standard Casper theme and I haven’t changed the default.hbs file.

I just copied the author.hbs file to create the custom page for separate authors.

I cannot understand why using {{#primary_author}} breaks the page. That is, it does not display information about the author.

It is hard to help you without seeing your default.hbs file contents.

Here is the content of the file

{{!-- Document Settings --}}
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

{{!-- Base Meta --}}
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

{{!-- Styles'n'Scripts --}}
<link rel="stylesheet" type="text/css" href="{{asset "built/screen.css"}}" />

{{!-- This tag outputs SEO meta+structured data and other important settings --}}
<div class="site-wrapper">

    {{!-- All the main content gets inserted here, index.hbs, post.hbs, etc --}}

    {{!-- The footer at the very bottom of the screen --}}
    <footer class="site-footer outer">
        <div class="site-footer-content inner">
            <section class="copyright"><a href="{{@site.url}}">{{@site.title}}</a> &copy; {{date format="YYYY"}}</section>
            <nav class="site-footer-nav">
                <a href="{{@site.url}}">Latest Posts</a>
                {{#if @site.facebook}}<a href="{{facebook_url @site.facebook}}" target="_blank" rel="noopener">Facebook</a>{{/if}}
                {{#if @site.twitter}}<a href="{{twitter_url @site.twitter}}" target="_blank" rel="noopener">Twitter</a>{{/if}}
                <a href="" target="_blank" rel="noopener">Ghost</a>


{{!-- The big email subscribe modal content --}}
{{#if @labs.members}}
<div class="subscribe-success-message">
    <a class="subscribe-close" href="javascript:;"></a>
    You've successfully subscribed to {{@site.title}}!

<div id="subscribe" class="subscribe-overlay">
    <a class="subscribe-close" href="#"></a>
    <div class="subscribe-overlay-content">
        {{#if @site.logo}}
            <img class="subscribe-overlay-logo" src="{{@site.logo}}" alt="{{@site.title}}" />
        <div class="subscribe-form">
            <h1 class="subscribe-overlay-title">Subscribe to {{@site.title}}</h1>
            <p class="subscribe-overlay-description">Stay up to date! Get all the latest & greatest posts delivered straight to your inbox</p>
            <form data-members-form="subscribe">
                <div class="form-group">
                    <input class="subscribe-email" data-members-email placeholder=""
                        autocomplete="false" />
                    <button class="button primary" type="submit">
                        <span class="button-content">Subscribe</span>
                        <span class="button-loader">{{> "icons/loader"}}</span>
                <div class="message-success">
                    <strong>Great!</strong> Check your inbox and click the link to confirm your subscription.
                <div class="message-error">
                    Please enter a valid email address!

{{!-- jQuery, required for fitvids --}}
{{!-- Fitvids (for responsive video embeds), infinite scroll, floating header, and gallery card support --}}
<script src="{{asset "built/casper.js"}}"></script>

{{!-- Scripts for Members subscription --}}
    // Parse the URL parameter
    function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));

    // Give the parameter a variable name
    var action = getParameterByName('action');

    $(document).ready(function () {
        if (action == 'subscribe') {

        $('.subscribe-success-message .subscribe-close').click(function () {

        // Reset form on opening subscrion overlay
        $('.subscribe-button').click(function() {
            $('.subscribe-overlay form').removeClass();

{{!-- The #block helper will pull in data from the #contentFor other template files. In this case, there's some JavaScript which we only want to use in post.hbs, but it needs to be included down here, after jQuery has already loaded. --}}
{{{block "scripts"}}}

{{!-- Ghost outputs important scripts and data with this tag - it should always be the very last thing before the closing body tag --}}

Are you still getting the original error as in your first post at the top of this thread, when you try to activate the theme? Did that go away?

If I use {{#author}}, an error will be shown when activating theme. But everything works as I need it to.

If I replace {{#author}} with {{#primary_author}}, the page will not show the header and the block with information about the author.

Have you tried running your theme through GScan?

Are you using Ghost(Pro) or self hosting?

I use the localhost version of Ghost.
Gscan shows the same bug.

Can someone tell me how to make a copy of authors.hbs so that Ghost doesn’t show the bug?

Or do I do everything right and that’s the problem with the Ghost engine?

Can you attach the entire file you’re having issues with to this thread? It’ll make it easier to work out what’s happening.

Here’s my file. I didn’t change anything in it, just copied author.hbs

{{!< default}}
{{!-- The tag above means - insert everything in this file into the {body} of the default.hbs template --}}

{{!-- Everything inside the #author tags pulls data from the author --}}

<header class="site-archive-header">
    {{> site-header}}
    {{> header-background background=cover_image}} {{!--Special header-image.hbs partial to generate the background image--}}
        <div class="inner">
            <div class="site-header-content author-header">
                {{#if profile_image}}
                    <img class="author-profile-image" src="{{profile_image}}" alt="{{name}}" />
                <div class="author-header-content">
                    <h1 class="site-title">{{name}}</h1>
                    {{#if bio}}
                        <h2 class="author-bio">{{bio}}</h2>
                    <div class="author-meta">
                        {{#if location}}
                            <div class="author-location">{{location}}</div>
                        <div class="author-stats">
                            {{plural ../ empty='No posts' singular='% post' plural='% posts'}}
                        {{#if website}}
                            <span class="author-social-link"><a href="{{website}}" target="_blank" rel="noopener">Website</a></span>
                        {{#if twitter}}
                            <span class="author-social-link"><a href="{{twitter_url}}" target="_blank" rel="noopener">Twitter</a></span>
                        {{#if facebook}}
                            <span class="author-social-link"><a href="{{facebook_url}}" target="_blank" rel="noopener">Facebook</a></span>

{{!-- The main content area --}}
<main id="site-main" class="site-main outer">
    <div class="inner posts">

        <div class="post-feed">
            {{#foreach posts}}

                {{!-- The tag below includes the markup for each post - partials/post-card.hbs --}}
                {{> "post-card"}}



@andrianov the error message you posted above shows that the Affected file is not author-and.hbs but author-konstantin.hbs,

I just renamed the file when I was doing another test.

The problem here is not the name, but whether to use {{#author}} in this template correctly and why Ghost should show the error?

Thank you @andrianov – yes, I believe I do understand the problem :eyes:

It is quite a frustrating puzzle :right_anger_bubble:

If you want a specific author template for yourself, then your filename (author-and.hbs) has to match your author slug (and?). You can check/set this on your profile page.

1 Like

My author slug is selected correctly, just like the author-and.hbs template.

I do everything as it is written in the documentation, but I think it’s a problem inside Ghost. If you leave it in the template {{#author}} then everything works, but the error in Ghost saying that it is wrong to do this.

Has anyone tried to test it at home? You just need to copy the author.hbs file and rename it according to author slug.