# Templates

With Server Pro, you have the ability to create and publish your own templates, within your self-hosted environment, as well as re-distribute downloaded templates from the [Template Gallery](https://www.overleaf.com/latex/templates) on [overleaf.com](https://www.overleaf.com).

## Setting up the templates user

In Server Pro, a single user is responsible for publishing the curated list of templates that are visible on your local template gallery `/templates`.

To do this, you'll need to set the environment variable `OVERLEAF_TEMPLATES_USER_ID` in `toolkit/config/variables.env` to the `ID` of the user who will be responsible for template management within your instance, for example:

```
OVERLEAF_TEMPLATES_USER_ID=56a8865231faeb5f07d69959
```

To obtain the `ID` of the user you wish to publish public templates:

1. Log in using an Administrator account and go to `Admin` > `Manage Users`.&#x20;
2. Search for the user using their email address and click through to their user admin page. There you will find the `ID`:&#x20;
3. Copy that `ID` and use it to set the environment variable `OVERLEAF_TEMPLATES_USER_ID`.
4. Run `bin/up -d` to recreate the `sharelatex` container and apply the change.

{% hint style="warning" %}
Altering the configuration files of Server Pro typically necessitates the recreation of one or more containers. This procedure will cause user disconnections and lead to a period of downtime. As such, we advise implementing these modifications during prearranged maintenance periods.
{% endhint %}

## Publishing templates

If you'd like to make templates available to all of your on-premise Server Pro users you'll need to:

1. Log in as the **templates user**.
2. As the **templates user**, create or upload a project containing the template's source code and make sure it compiles.
3. In the editor's left-hand menu, choose **Manage Template**.&#x20;
4. Enter a custom description of the template
5. Click the **Publish** button
6. Go to the project dashboard and tag the template with the name of the cateogry you'd like it to appear in. For example <mark style="color:green;">`Presentations`</mark>.

{% hint style="success" %}
Did you know that you can transfer quality, pre-built LaTeX templates that are available on the [Template Gallery](https://www.overleaf.com/latex/templates) at [overleaf.com](https://www.overleaf.com) to your on-premise instance of Server Pro? For more information see the Transferring templates section below.
{% endhint %}

## Unpublishing templates

If you'd like to unpublish a template you'll need to:

1. Log in as the **templates user**.
2. Open the previously existing project containing the template's source code.
3. In the editor's left-hand menu, choose **Manage Template**.
4. Once the confirmation popup is displayed, click **Unpublish**.

Once this has been done, the template should have been removed from the templates list.

## Linking to your templates

### Your gallery

On the templates gallery page, `/templates`, templates are grouped together using the tag which the user assigns to the projects, e.g. Journals, Reports etc. To see all templates add `/all` to the URL `/templates/all`, which can also be used as the default URL if you do not wish to use tags for groupings.

Like-wise, you can view/link to templates within a specific category by appending the tag name to the templates URL, for example: `/templates/journals`.

{% hint style="success" %}
Did you know that if you tag a project multiple times it will appear in multiple groups.
{% endhint %}

### New project menu

When a user creates a new project, they can be shown customized links to template categories. These links are set via the `OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS` environment variable in `toolkit/config/variables.env`, for example:

```
OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS='[
   {"name":"All Templates","url":"/templates/all"},
   {"name":"All Categories","url":"/templates"},
   {"name":"Reports","url":"/templates/reports"},  
   {"name":"External","url":"https://somewhere.com/templates/reports"}
]'
```

## Transferring templates from overleaf.com

As Server Pro has been architected to work offline, there isn't an automated way to integrate [overleaf.com](https://www.overleaf.com) gallery templates into your on-premise installation, it is however possible to do this manually on a per template basis.

By default, Server Pro is configured to use a basic scheme version of TeXLive for compiles. This basic version is lightweight and only contains a very limited subset of LaTeX packages which, will most likely result in missing package errors for your users when attempting to use templates from [overleaf.com](https://www.overleaf.com) on your local on-premise instance.

Unfortunately, whilst there isn't an automatic way to install missing packages, we do have a configurable setting within Server Pro that will allow your users to compile projects with access to more packages, and in a more secure way. This feature is called [Sandbox Compiles](/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/sandboxed-compiles.md) (also known as Sibling Containers).

To ensure that downloaded templates are compatible with your on-premise Server Pro instance, we highly recommend that you enable [Sandbox Compiles](/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/sandboxed-compiles.md) as this feature will provide your users with access to the same TeX Live environment as that on [overleaf.com](https://www.overleaf.com). These images contain the most popular packages and fonts and have already been tested against our gallery templates.

You can find additional information about configuring what TeX Live versions users are able to choose from within their project along with setting the default TeX Live image version for new projects in the [Changing the TeX Live Image](/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/sandboxed-compiles.md#changing-the-tex-live-image) section of our documentation.

1. Navigate to the [Template Gallery](https://www.overleaf.com/latex/templates) on [overleaf.com](https://www.overleaf.com) and locate the required template, for example [IEEE Photonics Journal Paper Template - Example Submission](https://www.overleaf.com/latex/examples/ieee-photonics-journal-paper-template-example-submission/bsfjjfkdsjds)
2. Click on the **Open as Template** button
3. Click on the project menu and choose **Download Source**
4. Next, log into the on-premise Server Pro account
5. Click the **New Project** button from the projects dashboard and choose **Upload Project**
6. Click the **Select a .zip file** button and choose the downloaded template zip file

The user can then use this newly uploaded template within their own account, or, as the templates user, you can publish it for other users to use.

{% hint style="info" %}
An [overleaf.com](https://www.overleaf.com) account is required.&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/server-pro-only-configuration/templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
