# Automatically fix links

**URL:** <https://talk.jekyllrb.com/t/automatically-fix-links/6057>\
**Category:** Uncategorized\
**Created:** [May 19, 2021, 1:23pm UTC](https://talk.jekyllrb.com/t/automatically-fix-links/6057 "2021-05-19T13:23:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 19, 2021, 1:23pm UTC](https://talk.jekyllrb.com/t/automatically-fix-links/6057/1 "2021-05-19T13:23:54Z")

</div>

Hello!

Controlling links in Jekyll honestly is really a mess and if you want to be able to host your site in a sub-folder you need to prepend `{{ site.baseurl }}` for each link.

So I’d like to know if there is a plugin or something that automatically prepends `site.baseurl` to each link.

Thanks!

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [May 19, 2021, 7:05pm UTC](https://talk.jekyllrb.com/t/automatically-fix-links/6057/2 "2021-05-19T19:05:33Z")

</div>

It sounds like you are spending a lot of time creating variables to build the url, but in general, you do not have to do that.

To get what you want, you should pipe in a filter for the `relative_url` or `absolute_url`.

## Relative url

```auto
<a href="{{- '/mypages/support.html' | relative_url -}}">Visit our support page</a>

```

The final result for the url could look something like this:

> /mywebsite/mypages/support.html

## Absolute url

Alternatively, you can use the absolute\_url filter, like this:

```auto
<a href="{{- '/mypages/support.html' | absolute_url -}}">Visit our support page</a>

```

The final result for the url could look something like this:

> [https://www.myurl.com/mywebsite/mypages/support.html](https://www.myurl.com/mywebsite/mypages/support.html)

## Further reading

You will of course need to do the one-time configuration of setting up your `_conifg.yml` file with the `base_url` and `url`. There’s an excellent definition of all this on the the official Jekyll documentation site:

> **[Liquid Filters](https://jekyllrb.com/docs/liquid/filters/)**
>
> All of the standard Liquid filters are supported (see below).

---

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 22, 2021, 6:24pm UTC](https://talk.jekyllrb.com/t/automatically-fix-links/6057/3 "2021-05-22T18:24:44Z")

</div>

Well that’s already better and that will definitely help me, so thanks! 👍

But we still need to put that `| relative_url` which can be a pain when having a lot of assets

Note : that doesn’t work with jekyll-multiple-languages-plugin

---

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 22, 2021, 6:25pm UTC](https://talk.jekyllrb.com/t/automatically-fix-links/6057/4 "2021-05-22T18:25:36Z")

</div>

Maybe I could make a plugin that automatically detects if there is a `/` at the beginning of the URL and prepend the relative or absolute URL if so 🤔
