Comment count helper outputs nothing

I am trying to use the {{comment_count}} helper in my theme, but I cannot get it to show anything. I want to show a heading above my comment section that says “No comments” or, for example, “5 comments”. Here is the code in my post.hbs template:

<h4>{{comment_count empty="No" autowrap=false}} Comments</h4>

Here is the output:

<h4><script data-ghost-comment-count="65f8c7b28652be68d8336c72" data-ghost-comment-count-empty="No" data-ghost-comment-count-singular="comment" data-ghost-comment-count-plural="comments" data-ghost-comment-count-tag="script" data-ghost-comment-count-class-name="" data-ghost-comment-count-autowrap="false">
</script> Comments</h4>
</script>

I am running Ghost 5.82.2 in a local development environment on Windows 11. Any help with troubleshooting this would be greatly appreciated.

1 Like

Could you have a look in the dev tools console for any errors? (F12 to open dev tools, then console tab.) I’m wondering if the script that should be processing this is not actually doing so…

1 Like

Good call. The request for comment-counts.min.js returns a 404 error. Progress! Any idea why this might happen? I wonder if it is a problem with the local dev environment.

1 Like

That’s a good guess. What url is it looking at? (You can see under the network tab, if it’s not obvious from the error message.)

On my local install, that file is in <ghost-directory>/content/public . If you’re using something Linux-like (or WSL), you may also need to check that permissions are correct.

Also check to see if your Ghost site is logging any errors when you make that request. What’s it say?

It may be helpful to add some details on your local install. What OS, how’d you set it up?

1 Like

What url is it looking at?

Mine is looking in <ghost-directory>/public. When I browse my Ghost directory in File Explorer, I do not see the file in /public nor /content/public.

Also check to see if your Ghost site is logging any errors when you make that request. What’s it say?

I checked the logs and did not see any relevant errors.

It may be helpful to add some details on your local install. What OS, how’d you set it up?

As I mentioned in my initial post, I am running Ghost 5.82.2 on Windows 11 (not WSL). I installed it with the Ghost CLI using the ghost install local command.

1 Like

I know that ghost on windows (not wsl) fails to correctly generate the card assets that also live in this folder. I’m guessing this is the same bug, which has a pr but wasn’t merged because the fix impacted production deploys.

I highly recommend wsl instead.

2 Likes

That did the trick. The files are present and work as expected on WSL. Honestly, I prefer WSL for Ghost development because it is much closer to my production environment. I only switched back to native Windows when I found that I could not open BrowserSync’s live preview on my phone when launched from WSL.

Thank you very much for the assistance, Cathy.

2 Likes