# Modifying head\_tag.html template

**URL:** https://meta.discourse.org/t/modifying-head-tag-html-template/116012
**Category:** Development
**Created:** [April 25, 2019, 9:06pm UTC](https://meta.discourse.org/t/modifying-head-tag-html-template/116012 "2019-04-25T21:06:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sodevious](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sodevious/32/141165_2.png) [@sodevious](https://meta.discourse.org/u/sodevious)
#### Post date: [April 25, 2019, 9:06pm UTC](https://meta.discourse.org/t/modifying-head-tag-html-template/116012/1 "2019-04-25T21:06:53Z")

</div>

I am working on a custom theme and am a little confused regarding how I can access/edit what’s in the `<head>`. I see the file `head_tag.html`, and of course when you edit it, it overrides the existing template. Cool, but how do I find the existing content? I’ve read and re-read this: [Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648) and also looked through [https://github.com/discourse/discourse/tree/master/app/assets/javascripts/discourse/templates](https://github.com/discourse/discourse/tree/master/app/assets/javascripts/discourse/templates)

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [April 26, 2019, 12:48am UTC](https://meta.discourse.org/t/modifying-head-tag-html-template/116012/2 "2019-04-26T00:48:07Z")

</div>

While you can add to it - like you’ve already discovered - you can’t modify the existing contents of the `<head>` tag in a theme because it’s generated based on `.erb` files and themes don’t have access to that.

[discourse/app/views/layouts/application.html.erb at eae22548de4eedad875555e7353b8abfdce2452b · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/eae22548de4eedad875555e7353b8abfdce2452b/app/views/layouts/application.html.erb#L3-L64)

with a another file that’s loaded as a partial here

[discourse/app/views/layouts/\_head.html.erb at eae22548de4eedad875555e7353b8abfdce2452b · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/eae22548de4eedad875555e7353b8abfdce2452b/app/views/layouts/_head.html.erb)

It’s possible that there maybe JavaScript workarounds to achieve what you’re trying to do. I might be able to advise if you can give me a simple example of the desired changes.

---

<div class="post-metadata">

### Author: ![sodevious](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sodevious/32/141165_2.png) [@sodevious](https://meta.discourse.org/u/sodevious)
#### Post date: [April 26, 2019, 1:01am UTC](https://meta.discourse.org/t/modifying-head-tag-html-template/116012/3 "2019-04-26T01:01:22Z")

</div>

Hi Joe, the Theme CLI tool creates the `head.html` file. So if it practically can’t be used, I am confused as to it’s purpose?

Initially I wanted to import fonts via a `<link>` tag in the head, but I resolved that with a CSS import instead.

---

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [April 26, 2019, 1:40am UTC](https://meta.discourse.org/t/modifying-head-tag-html-template/116012/4 "2019-04-26T01:40:11Z")

</div>

Thanks for clarifying.

What you want to do is actually possible in a theme. I initially thought you were trying to modify the existing tags in the document `<head>` tag that are added by Discourse.

A theme can add arbitrary tags to the document `<head>` tag without issues. That’s the purpose of the `head_tag.html` file that the Theme CLI generates.

The `head_tag.html` file correlates to the `</head>` tab in the theme editor

 ![theme1](https://global.discourse-cdn.com/meta/original/3X/2/e/2e1e729a08f26efcd1f9f2702b68823f1f620afc.png)

Any valid html you add there will be injected in the document `<head>` tag. Notice that I said injected - you don’t override the existing tags, your html just gets added to them. It would be added here (simplified screenshot)

 ![theme5](https://global.discourse-cdn.com/meta/original/3X/d/e/ded84eb72c65d9e300d0f545905147dd43b25fbd.png)

So if you want to add a `<link>` tag for a font like this one for example

```plaintext
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">

```

you would just need to add it to the `head_tag.html` file that the Theme CLI generates and it should show up. (simplified screenshot)

 ![theme6](https://global.discourse-cdn.com/meta/original/3X/9/1/91076d61fb0d6f90eb41f5294f0daf3341c1906b.png)

Do note that unlike CSS changes, this requires a page refresh to actually work.

Let me know if you need any clarification.
