# Allowing redirect pages to use a template

**URL:** <https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982>\
**Category:** Feature requests\
**Created:** [December 21, 2023, 2:07pm UTC](https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982 "2023-12-21T14:07:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [December 21, 2023, 2:07pm UTC](https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982/1 "2023-12-21T14:07:11Z")

</div>

If you use `aliases` or `redirect_to` for sections, an html page is generated to perform a redirect. However, it would be beneficial to allow these redirect pages to have access to template, to update titles and set various meta tags.

For example:

This is an example of how a link to my blog post looks when I share it in a messaging app:

 ![Screenshot 2023-12-21 at 3.03.03 PM](https://global.discourse-cdn.com/free1/uploads/zola1/original/2X/a/aa656adff3f5b4b9e34561ed96ad73b0166de381.png)

For contrast, here is a preview to a link that performs a redirect:

 ![Screenshot 2023-12-21 at 3.05.53 PM](https://global.discourse-cdn.com/free1/uploads/zola1/original/2X/c/c7e4dcffed0c8db37e0af16a0af75d4d00e3516f.png)

Being able to template the redirect page would allow the title to be set, as well as a description, and meta tags for SEO and social media previews.

---

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [December 21, 2023, 2:35pm UTC](https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982/2 "2023-12-21T14:35:21Z")

</div>

I _think_ this could be done by supplying the necessary context to the `render_redirect_template` function:

```rs
/// Renders the `internal/alias.html` template that will redirect
/// via refresh to the url given
pub fn render_redirect_template(url: &str, tera: &Tera) -> Result<String> {
    let mut context = Context::new();
    context.insert("url", &url);

    tera.render("internal/alias.html", &context)
        .with_context(|| format!("Failed to render alias for '{}'", url))
}

```

And then the user could just make their own template file under `internal/alias.html`.

---

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [December 21, 2023, 2:43pm UTC](https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982/3 "2023-12-21T14:43:20Z")

</div>

However, there’s a chance then that the user might break the redirect functionality by not including the correct HTML in the template, so more work would have to be done no the rust side to prevent that from happening.

I’m interested @keats has any suggestions or doesn’t think this is a good idea to begin with.

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [December 22, 2023, 7:40am UTC](https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982/4 "2023-12-22T07:40:53Z")

</div>

We could put the title automatically in the built-in template but for meta tags it would need to be a template yes, and zola needs to check whether the correct redirect is present

---

<div class="post-metadata">

**Author:** ![florian-obernberger](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/florian-obernberger/32/1484_2.png) [@florian-obernberger](https://zola.discourse.group/u/florian-obernberger)\
**Post date:** [June 16, 2025, 8:57am UTC](https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982/5 "2025-06-16T08:57:07Z")

</div>

Since I am currently stumbling about the same thing—wanting redirects to also include metadata (opengraph, twitter card etc.)—I wanted to ask if this is possible already?

I know I cannot access a `page` variable, but maybe I am just missing a setting or smf similar?

Either way: thanks so much for any help! ^^

---

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [June 16, 2025, 9:40am UTC](https://zola.discourse.group/t/allowing-redirect-pages-to-use-a-template/1982/6 "2025-06-16T09:40:02Z")

</div>

I haven’t done it yet. It’s a pretty minor change though if anyone has the time.
