| 1 |
--- |
| 2 |
title: URL |
| 3 |
description: Returns the relative permalink of the page associated with the given menu entry, else its `url` property. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: string |
| 9 |
signatures: [MENUENTRY.URL] |
| 10 |
--- |
| 11 |
|
| 12 |
For menu entries associated with a page, the `URL` method returns the page's [`RelPermalink`][], otherwise it returns the entry's `url` property. |
| 13 |
|
| 14 |
```go-html-template |
| 15 |
<ul> |
| 16 |
{{ range .Site.Menus.main }} |
| 17 |
<li><a href="{{ .URL }}">{{ .Name }}</a></li> |
| 18 |
{{ end }} |
| 19 |
</ul> |
| 20 |
``` |
| 21 |
|
| 22 |
[`RelPermalink`]: /methods/page/relpermalink/ |