# Applying code-injection through internal tags do not appear in site

**URL:** <https://forum.ghost.org/t/applying-code-injection-through-internal-tags-do-not-appear-in-site/36527>\
**Category:** Developer help\
**Created:** [February 20, 2023, 5:24am UTC](https://forum.ghost.org/t/applying-code-injection-through-internal-tags-do-not-appear-in-site/36527 "2023-02-20T05:24:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rickaym](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/rickaym/32/20699_2.png) [@Rickaym](https://forum.ghost.org/u/Rickaym)\
**Post date:** [February 20, 2023, 5:24am UTC](https://forum.ghost.org/t/applying-code-injection-through-internal-tags-do-not-appear-in-site/36527/1 "2023-02-20T05:24:41Z")

</div>

- **What’s your URL**? [About](https://philiasophia.org/about/)
- **What version of Ghost are you using?** Latest

And

- How was Ghost installed and configured?  
Ubuntu Install on Debian

- What Node version, database, OS & browser are you using?  
Node 16.16.0, MySQL, Debian, Chrome

- What errors or information do you see in the console?  
None

- What steps could someone else take to reproduce the issue you’re having?  
Create an internal tag with a header code injection:

```auto
<script>
    addEventListener('DOMContentLoaded', (e) => {
        document.querySelector("h1.gh-article-title").hidden = true;
        document.querySelector("main").style.paddingTop = 0;
        document.querySelector(".gh-content.gh-canvas").style.marginTop = 0;
    });
</script>

```

And being on the Journal theme this would remove the header completely and its padding and margins.

However in my case, the code injection is not applied and the header persist.

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [February 20, 2023, 5:22pm UTC](https://forum.ghost.org/t/applying-code-injection-through-internal-tags-do-not-appear-in-site/36527/2 "2023-02-20T17:22:20Z")

</div>

I just tried manually running `document.querySelector("h1.gh-article-title").hidden = true;` in my browser console, and the 'About" disappeared appropriately. So I suspect that your event listener isn’t firing. Can you add a `console.log('triggered!')` into the code injection, to get some more information about whether it’s firing?

The example I see online that looks like what you’re trying to do has this:…

```auto
window.addEventListener('DOMContentLoaded', (event) => {
# do stuff })

```

So if it isn’t firing, try attaching the event listener to the window?

---

<div class="post-metadata">

**Author:** ![Rickaym](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/rickaym/32/20699_2.png) [@Rickaym](https://forum.ghost.org/u/Rickaym)\
**Post date:** [February 21, 2023, 6:21am UTC](https://forum.ghost.org/t/applying-code-injection-through-internal-tags-do-not-appear-in-site/36527/3 "2023-02-21T06:21:55Z")

</div>

It’s not that the event is not firing–and I’ve tried console.log and it doesn’t go through. It’s that the injection is not appearing in the tag at all for some reason although the tag is added and configured properly.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/3X/5/1/51fdb3ef899a3a036f4d12ab66d1b050dd0006fc.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/3X/8/d/8d9f363be35a0aa078189a50c48f9638a043cf4f.png)

---

<div class="post-metadata">

**Author:** ![Cathy\_Sarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cathy_sarisky/32/25750_2.png) [@Cathy\_Sarisky](https://forum.ghost.org/u/Cathy_Sarisky)\
**Post date:** [February 21, 2023, 8:48am UTC](https://forum.ghost.org/t/applying-code-injection-through-internal-tags-do-not-appear-in-site/36527/4 "2023-02-21T08:48:21Z")

</div>

> [@Rickaym](#):
>
> tried console.log and it doesn’t go through

Meaning you do or don’t see “triggered” in the console log?

---

<div class="post-metadata">

**Author:** ![RyanF](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ryanf/32/17448_2.png) [@RyanF](https://forum.ghost.org/u/RyanF)\
**Post date:** [February 21, 2023, 4:15pm UTC](https://forum.ghost.org/t/applying-code-injection-through-internal-tags-do-not-appear-in-site/36527/5 "2023-02-21T16:15:37Z")

</div>

This took me a second to understand, but here’s the story:

Those code injection fields are for the tag pages themselves, not for posts or pages that have those tags. That means that a code injection for a public tag will run on `/tag/slug` but not on a post with that slug. For this reason, your approach won’t work.

However, there are other approaches.

1. Most themes will already include all tags as classes on a post using Ghost’s [post class](https://ghost.org/docs/themes/helpers/post_class/). For a private tag of test, it’ll output a class of `hash-tag-test`, which you can then target with CSS.

2. Theme level: Edit your theme to conditionally apply classes based on the presence of the private/internal tag.

```plaintext
{{! post.hbs }}
<article class="card {{#has tag="#test"}}card-extra-styling{{/has}}> ... 

```
