urls.AbsURL
语法
urls.AbsURL INPUT
返回值
string
别名
absURL
对于多语言配置,请改用 urls.AbsLangURL
函数。此函数返回的 URL 取决于
- 输入是否以斜杠开头
- 站点配置中的
baseURL
输入不以斜杠开头
如果输入不以斜杠开头,则结果 URL 中的路径将相对于站点配置中的 baseURL
。
当 baseURL = https://example.org/
时
{{ absURL "" }} → https://example.org/
{{ absURL "articles" }} → https://example.org/articles
{{ absURL "style.css" }} → https://example.org/style.css
当 baseURL = https://example.org/docs/
时
{{ absURL "" }} → https://example.org/docs/
{{ absURL "articles" }} → https://example.org/docs/articles
{{ absURL "style.css" }} → https://example.org/docs/style.css
输入以斜杠开头
如果输入以斜杠开头,则结果 URL 中的路径将相对于站点配置中 baseURL
的协议+主机。
当 baseURL = https://example.org/
时
{{ absURL "/" }} → https://example.org/
{{ absURL "/articles" }} → https://example.org/articles
{{ absURL "/style.css" }} → https://example.org/style.css
当 baseURL = https://example.org/docs/
时
{{ absURL "/" }} → https://example.org/
{{ absURL "/articles" }} → https://example.org/articles
{{ absURL "/style.css" }} → https://example.org/style.css