How to verify if I am on a custom page?

Hello, good day to everyone.

I wanted to see if anyone could support me with their Ghost experience on whether what I’m doing is okay or if there is a better way to do it.

Currently all my templates take default.hbs as a reference to build. In this file I check what type of page it is on, in order to load the correct assets.

{{#is "bits"}}
    <link rel='stylesheet' href='{{asset "styles/bit-bundle.css"}}'>

{{#is "videos"}}
    <link rel='stylesheet' href='{{asset "styles/video-bundle.css"}}'>

I ran into the problem that I have post.hbs and also custom-post-name.hbs in which I want to load other types of scripts, that’s why I did the following:

{{#is "post"}}
       {{#has tag="blog"}}
            <link rel='stylesheet' href='{{asset "styles/post-bundle.css"}}'>
        {{#has tag="bit"}}
            <link rel='stylesheet' href='{{asset "styles/postBit-bundle.css"}}'>

Is there a better way to do this? Maybe something like {{#has custom-post-name}} or would it be better to create another default-custom-post.hbs file?

Thank you in advance for your comments.

Hi, I have just answered similar type of question, Actually honestly I did not clearly understand. Also there is some non English ( probably Spanish ) in your question.

Is “bits” and “videos” in first comment block are post collections? Are those collections are made via route based on tags? are those collections are using custom template?

Anyways you can try and play with {{{block}}} and {{contentFor}} heplers. Maybe these can help you. See this thread for better understanding how they works.


Content block helpers are a good solution, you could dictate the CSS file loaded within that template file, rather than conditionally applying them from another file.

1 Like