| 1 |
--- |
| 2 |
title: BaseURL |
| 3 |
description: Returns the base URL as defined in your project configuration. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: string |
| 9 |
signatures: [SITE.BaseURL] |
| 10 |
--- |
| 11 |
|
| 12 |
Project configuration: |
| 13 |
|
| 14 |
{{< code-toggle file=hugo >}} |
| 15 |
baseURL = 'https://example.org/docs/' |
| 16 |
{{< /code-toggle >}} |
| 17 |
|
| 18 |
Template: |
| 19 |
|
| 20 |
```go-html-template |
| 21 |
{{ .Site.BaseURL }} → https://example.org/docs/ |
| 22 |
``` |
| 23 |
|
| 24 |
> [!note] |
| 25 |
> There is almost never a good reason to use this method in your templates. Its usage tends to be fragile due to misconfiguration. |
| 26 |
> |
| 27 |
> Use the [`absURL`], [`absLangURL`], [`relURL`], or [`relLangURL`] functions instead. |
| 28 |
|
| 29 |
[`absLangURL`]: /functions/urls/absLangURL/ |
| 30 |
[`absURL`]: /functions/urls/absURL/ |
| 31 |
[`relLangURL`]: /functions/urls/relLangURL/ |
| 32 |
[`relURL`]: /functions/urls/relURL/ |