# \[SOLVED\] Issues with implementing templates

**URL:** <https://forum.gitea.com/t/solved-issues-with-implementing-templates/449>\
**Category:** Install/Maintain/Configure\
**Created:** [July 25, 2018, 3:38pm UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449 "2018-07-25T15:38:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkraul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/bkraul/32/4728_2.png) [@bkraul](https://forum.gitea.com/u/bkraul)\
**Post date:** [July 25, 2018, 3:38pm UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449/1 "2018-07-25T15:38:28Z")

</div>

Been trying to implement custom templates on my gitea installation for a while. I am using the docker implementation.

I have checked the gitea documentation on templating and configuration, but the documentation is honestly pretty vague.

The last indication from @lafriks suggests the following:

> As for custom folder it specified in `GITEA_CUSTOM` variable or by default it is `$GITEA_WORK_DIR/custom`

> Custom templates need to be placed in `$GITEA_CUSTOM/custom/templates/custom/` directory

However, there is no information under the documentation as to what category the `GITEA_CUSTOM` variable goes under. I added it under the `[ui]` and then at the top (no category), to no avail.

The desired value for `GITEA_CUSTOM` is `/data/gitea/custom` (in docker, I am assuming the `$GITEA_WORK_DIR` resolves to `/data/gitea`, but even this I don’t know for sure. The app.ini file says that `APP_DATA_PATH` resolves `/data/gitea`).

Interestingly enough, `printenv` inside the container has no mention of `GITEA_WORK_DIR`, but it shows `GITEA_CUSTOM` as `/data/gitea`

As such, I have put my template files in the following places, hoping that at least one of the locations would get picked up:

- `/data/gitea/custom/templates/custom/header.tmpl`
- `/data/gitea/custom/templates/header.tmpl`
- `/data/gitea/custom/header.tmpl`
- `/data/gitea/templates/custom/header.tmpl`
- `/data/gitea/templates/header.tmpl`

All of the files have a single value: `<!-- this is a test to see if it is picked up by gitea -->`.

I do take care of taking down the docker container and restarting it (something that I have seen mentioned).

However, when looking at the html source of the gitea app, the code introduced in my template is nowhere to be found. I have cleared browser cache, logged out, logged back in, to no avail.

Thanks in advance to anyone who has made this work and has some info on how this is supposed to go.

---

<div class="post-metadata">

**Author:** ![bkraul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/bkraul/32/4728_2.png) [@bkraul](https://forum.gitea.com/u/bkraul)\
**Post date:** [July 25, 2018, 3:55pm UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449/2 "2018-07-25T15:55:20Z")

</div>

**Update:** I realized the `GITEA_CUSTOM` variable is not an app.ini variable, but one that is specified at the ENV level (at least in docker), so I removed it from app.ini. The default `GITEA_CUSTOM` per `printenv` resolves to `/data/gitea`. But knowing this for sure still does not solve my issue, because I do have a template file in `/data/gitea/templates/custom/header.tmpl` which is not getting picked up.

---

<div class="post-metadata">

**Author:** ![bkraul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/bkraul/32/4728_2.png) [@bkraul](https://forum.gitea.com/u/bkraul)\
**Post date:** [July 25, 2018, 4:27pm UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449/3 "2018-07-25T16:27:26Z")

</div>

It turns out, for anyone who experiences this: apparently the templating engine strips out all html comments from the code. This is why I could not see my comment being picked up. In my case, with `GITEA_CUSTOM` being mapped to `/data/gitea`, the full, correct path to my template file was `/data/gitea/templates/custom/header.tmpl`.

With this information I understand better and can move my files to a more structured location. Hope this helps anyone. If in doubt, the `printenv` command will tell you exactly where `GITEA_CUSTOM` is pointing, even inside a docker container (have to use `docker exec`).

Thanks to @lafriks for the help.

---

<div class="post-metadata">

**Author:** ![bkraul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/bkraul/32/4728_2.png) [@bkraul](https://forum.gitea.com/u/bkraul)\
**Post date:** [July 25, 2018, 5:01pm UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449/4 "2018-07-25T17:01:22Z")

</div>

**Further question:** So, now that I have been able to identify where my header.tmpl file should be located, I am now trying to figure out how I call out my custom css files, specifically what path to put in my `<link>` tags, and really for any additional assets I want to have. I am pretty positive there is no info on this on the documentation (`{{AppSubUrl}}` doesn’t seem to work, it returns an empty value).

Based on my particular environment I have tried `/data/gitea/templates/custom/myfile.css`, but the link returns a 404 response. What path do I need to use?

---

<div class="post-metadata">

**Author:** ![bkraul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/bkraul/32/4728_2.png) [@bkraul](https://forum.gitea.com/u/bkraul)\
**Post date:** [July 25, 2018, 5:11pm UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449/5 "2018-07-25T17:11:36Z")

</div>

**Resolution:** After looking closer into what the documentation says (actually applied to different matter), I realized I needed to have a public folder where my assets are to be found. I created this folder under my `GITEA_CUSTOM/public`, and placed my assets there. After doing this, gitea picked up my files and I am now good to go. All I can say is, goodness gracious. Hopefully someone finds this helpful, which is why I left the whole process.

---

<div class="post-metadata">

**Author:** ![bkraul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/bkraul/32/4728_2.png) [@bkraul](https://forum.gitea.com/u/bkraul)\
**Post date:** [July 25, 2018, 8:26pm UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449/6 "2018-07-25T20:26:42Z")

</div>

Looking nice 😄, more GitHub-like…Heh.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/1X/d3c79f71adb3be0b99147deb578e86185bf9c4dd.png)

---

<div class="post-metadata">

**Author:** ![techknowlogick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/techknowlogick/32/4706_2.png) [@techknowlogick](https://forum.gitea.com/u/techknowlogick)\
**Post date:** [July 26, 2018, 1:27am UTC](https://forum.gitea.com/t/solved-issues-with-implementing-templates/449/7 "2018-07-26T01:27:12Z")

</div>

Closed on July 26, 2018, 1:27am UTC


