Way to access NODE_ENV or similar in templates for inserting staging vs prod analytics code

Hi there,

I’m trying to set up ghost with identical apps in a staging and prod environment. My analytics vendor (heap) gives me different codes for “prod” vs “dev” environments to put in the analytics script in the head. Is there a convenient way in the templates to tell which environment I’m in? I know handlebars doesn’t do string comparison in its templates. I’m looking for something like:

{{#if @blog.prod }}prodSnippet{{else}}devSnippet{{/if}}

But of course, @blog.prod isn’t a real thing. Is there something like this, or do i need to figure out how to add custom handlebars helpers?

(If it matters: I’m self-hosting but I bought my theme; I didn’t develop it myself.)

We do this across our ghost sites internally using the Code Injection feature. So far haven’t found a use case which isn’t solvable with that :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.