メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

Base URL

base, base_url, current_url

Description​

{{ base }}
{{ base_url }}
{{ current_url }}
TagOutputExample
{{ base }}URL path of the site root, without a trailing slash. Empty when the site is at the document root(empty), /sub
{{ base_url }}Scheme, host (and port) plus {{ base }}: the absolute URL of the site roothttps://example.com, https://example.com/sub
{{ current_url }}Absolute URL of the current request, including the query stringhttps://example.com/news/?p=2

All three are HTML-escaped.

Start every link and asset path with {{ base }}/, so the site keeps working when it is installed in a subdirectory. Use {{ base_url }} and {{ current_url }} where an absolute URL is required (canonical, OGP).

Example​

Template
<link rel="stylesheet" href="{{ base }}/data/css/style.css">
<a href="{{ base }}/news/">News</a>
<img src="{{ base }}/data/img/common/pc/logo.png" alt="">

<link rel="canonical" href="{{ current_url }}">
<meta property="og:image" content="{{ base_url }}/data/img/ogp.png">
Output (site at https://example.com/, page /news/?p=2)
<link rel="stylesheet" href="/data/css/style.css">
<a href="/news/">News</a>
<img src="/data/img/common/pc/logo.png" alt="">

<link rel="canonical" href="https://example.com/news/?p=2">
<meta property="og:image" content="https://example.com/data/img/ogp.png">