mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
@@ -1,23 +1,18 @@
|
||||
---
|
||||
title: safe.URL
|
||||
linkTitle: safeURL
|
||||
description: Declares the provided string as a safe URL or URL substring.
|
||||
categories: [functions]
|
||||
description: Declares the given string as a safe URL or URL substring.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [safeURL]
|
||||
related:
|
||||
- functions/safe/CSS
|
||||
- functions/safe/HTML
|
||||
- functions/safe/HTMLAttr
|
||||
- functions/safe/JS
|
||||
- functions/safe/JSStr
|
||||
returnType: template.URL
|
||||
signatures: [safe.URL INPUT]
|
||||
relatedFunctions:
|
||||
- safe.CSS
|
||||
- safe.HTML
|
||||
- safe.HTMLAttr
|
||||
- safe.JS
|
||||
- safe.JSStr
|
||||
- safe.URL
|
||||
aliases: [/functions/safeurl]
|
||||
---
|
||||
|
||||
@@ -27,7 +22,7 @@ Without `safeURL`, only the URI schemes `http:`, `https:` and `mailto:` are cons
|
||||
|
||||
The following examples use a [site `hugo.toml`][configuration] with the following [menu entry][menus]:
|
||||
|
||||
{{< code-toggle file="hugo" copy=false >}}
|
||||
{{< code-toggle file=hugo >}}
|
||||
[[menu.main]]
|
||||
name = "IRC: #golang at freenode"
|
||||
url = "irc://irc.freenode.net/#golang"
|
||||
@@ -35,7 +30,7 @@ url = "irc://irc.freenode.net/#golang"
|
||||
|
||||
The following is an example of a sidebar partial that may be used in conjunction with the preceding front matter example:
|
||||
|
||||
{{< code file="layouts/partials/bad-url-sidebar-menu.html" copy=false >}}
|
||||
{{< code file=layouts/partials/bad-url-sidebar-menu.html >}}
|
||||
<!-- This unordered list may be part of a sidebar menu -->
|
||||
<ul>
|
||||
{{ range .Site.Menus.main }}
|
||||
@@ -55,7 +50,7 @@ This partial would produce the following HTML output:
|
||||
|
||||
The odd output can be remedied by adding ` | safeURL` to our `.URL` page variable:
|
||||
|
||||
{{< code file="layouts/partials/correct-url-sidebar-menu.html" copy=false >}}
|
||||
{{< code file=layouts/partials/correct-url-sidebar-menu.html >}}
|
||||
<!-- This unordered list may be part of a sidebar menu -->
|
||||
<ul>
|
||||
<li><a href="{{ .URL | safeURL }}">{{ .Name }}</a></li>
|
||||
|
Reference in New Issue
Block a user