Design of Custom "contact.html" page

Hello everybody,

I have Gitea installed on a shared web host in ~/gitea and it’s running very well.

Now I wanted to add a custom Contact HTML page which I placed in ~/gitea/custom/public/contact.html. After restarting Gitea, the new HTML page appeared on https://git.example.com/assets/contacts.html but of course it does not match the design of Gitea’s default theme.

Placing a “Contact” link in ~/gitea/custom/templates/custom/extra_links.tmpl was no problem. But I still don’t understand the connection between the contact.html and the template system. I don’t want to use a completely new template, I just want to adapt this new HTML file to Gitea’s existing design.

What’s the best way to handle this? The documentation is rather vague on this point. Do I need to save a new contact.tmpl somewhere? And if so, what content must it have?

I am grateful for every suggestion.

Best regards
Splendor

Well, what you did is (as you noticed yourself) defining an asset, not a template.
A template is simply an HTML document with another file extension where Go will evaluate the content of any {{…}} inside, and replace whatever the evaluation outputted with the {{…}}.
If there are none such as in a normal HTML file, then it will be treated as an HTML file.
Gitea queries its templates by default from $CUSTOM/templates instead of $CUSTOM/public.
You should be able to get the default Gitea style by including base/head_style.tmpl in your document header like so:

<head>
{{template "base/head_style"}}
</head>
<body>
…
</body>
1 Like

Thanks for your help, I really appreciate that. :slight_smile:

But unfortunately I still don’t get it.

I placed {{template "base/head_style"}} in my ~/gitea/custom/public/contact.html which now looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
	{{template "base/head_style"}}
</head>
<body>
    <h1>Contact</h1>
	<p>Lorem ipsum dolor sit amet.</p>
</body>
</html>

But after restarting Gitea, the web browser gives me the following output for the contact.html file:

{{template "base/head_style"}}

**Contact**

Lorem ipsum dolor sit amet.

The next thing I tried was grabbing the head_style.tmpl from the Gitea source code in templates/base and placing it on my web server in ~/gitea/custom/templates/base. But after restarting Gitea, the contact.html in my web browser still shows up without any styling:

{{template "base/head_style"}}

**Contact**

Lorem ipsum dolor sit amet.

(By the way: if i place all the template files from Giteas templates/base on my web server in ~/gitea/custom/templates/base), restarting Gitea will give me gitea: ERROR (spawn error) on the bash and 502 Bad Gateway -- nginx showing up in the web browser.)

I would be very happy about any further help.