# Relative URLs, Redirects and Pagination

**URL:** https://discourse.gohugo.io/t/relative-urls-redirects-and-pagination/14518
**Category:** support
**Tags:** pagination
**Created:** [October 1, 2018, 3:34pm UTC](https://discourse.gohugo.io/t/relative-urls-redirects-and-pagination/14518 "2018-10-01T15:34:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rhewitt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rhewitt/32/332_2.png) [@rhewitt](https://discourse.gohugo.io/u/rhewitt)
#### Post date: [October 1, 2018, 3:34pm UTC](https://discourse.gohugo.io/t/relative-urls-redirects-and-pagination/14518/1 "2018-10-01T15:34:37Z")

</div>

Are relativeURLs, redirects and pagination fundamentally at odds? I can’t seem to configure my site such that both work consistently. Possibly related to [#2199 Investigate RelativeURLs=true and aliases](https://github.com/gohugoio/hugo/issues/2199)

Let’s say I have `relativeURLs` enabled for the scenarios below.

I create a page with an alias and I **do not** have baseURL set. The generated alias doesn’t seem to bring along the relativeURL goodness:

## Frontmatter

```auto
---
title: Jobs in the Southeast
url: /work-with-us
aliases:
    - /jobs
---

```

## Generated alias page

```auto
<!DOCTYPE html>
<html>
  <head>
    <title>/work-with-us/</title>
    <!-- should be ../work-with-us/ -->
    <link rel="canonical" href="/work-with-us/"/>
    <meta name="robots" content="noindex">
    <meta charset="utf-8" />
    <meta http-equiv="refresh" content="0; url=/work-with-us/" />
  </head>
</html>

```

## Adding baseURL

With `baseURL=https://www.fws.gov/southeast` I can get the aliases to work as expected, but then my pagination links break as it starts to mash together baseURL and relative paths.

```auto
<!-- redirect works as expected -->
<meta http-equiv="refresh" content="0; url=https://www.fws.gov/southeast/work-with-us/" />

<!-- should be ../articles/ -->
<a href="../southeast/southeast/articles/">1</a>

```

## Customizing alias.html

I figured I could just customize my alias.html page in order to get around this. Unfortunately I can’t access the .Site or $.Site variables to access a site parameter.

```auto
<link rel="canonical" href="{{ .Site.Params.base }}{{ .Permalink }}" />

Error: Error building site: template: alias.html:6:36: executing "alias.html" at <$.Site.Params.base>: can't evaluate field Site in type struct { Permalink string; Page *hugolib.Page }

```

---

<div class="post-metadata">

### Author: ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)
#### Post date: [October 1, 2018, 11:24pm UTC](https://discourse.gohugo.io/t/relative-urls-redirects-and-pagination/14518/2 "2018-10-01T23:24:13Z")

</div>

What about your other templates (for pagination), and config? Do you have a minimal example repo to reproduce this? It seems like you’d fix this in the pagination template, ne?

---

<div class="post-metadata">

### Author: ![rhewitt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rhewitt/32/332_2.png) [@rhewitt](https://discourse.gohugo.io/u/rhewitt)
#### Post date: [October 2, 2018, 11:45am UTC](https://discourse.gohugo.io/t/relative-urls-redirects-and-pagination/14518/3 "2018-10-02T11:45:44Z")

</div>

I need to set up a minimalist version of my repo to share here. The repo on GitHub is currently 7GB and I don’t expect folks to download to help me out.

I seem to have found a solution as you suggested. I reintroduced a `baseURL` variable in my site config and used `{{ .URL | absURL }}` to generate the pagination links. The `baseURL` variable seems to have been used to generate the aliases, too.

## Pagination

```auto
  <li>
    <a href="https://www.fws.gov/southeast/articles/page/2/" aria-label="Next" class="pagination-next">
      <span aria-hidden="true">&raquo;</span>
    </a>
  </li>

```

## Alias (/jobs)

```auto
<!DOCTYPE html>
<html>
  <head>
    <title>https://www.fws.gov/southeast/work-with-us/</title>
    <link rel="canonical" href="https://www.fws.gov/southeast/work-with-us/"/>
    <meta name="robots" content="noindex">
    <meta charset="utf-8" />
    <meta http-equiv="refresh" content="0;url=https://www.fws.gov/southeast/work-with-us/" />
  </head>
</html>

```
