diff --git a/markup/functions/url.md b/markup/functions/url.md new file mode 100644 index 00000000..ef232a07 --- /dev/null +++ b/markup/functions/url.md @@ -0,0 +1,51 @@ +# url_*() + +## url() + +The `url()` function generates a fully qualified URL to the given path. + +```twig +{{ url('blog') }} + +{# https://site.com/blog #} +``` + +You can specify a variable as a function parameter: + +```twig +{{ url(category.slug) }} + +{# https://site.com/slug-value #} +``` + +In function parameters you can use concatenation: + +```twig +{{ url('blog/post/' ~ post.id) }} + +{# https://site.com/blog/post/123 #} +``` + +### Base URL + +You can get the base url like this: + +```twig +{{ url('/') }} + +{# https://site.com/ #} +``` + +## url_current() + +The `url_current()` function generates a fully qualified URL to the current path. Syntax: + +```twig +{{ url_current() }} +``` + +An example of generating a canonical link using the `url_current()` function and the `|lower` Twig filter: + +```twig + +``` diff --git a/markup/toc.yaml b/markup/toc.yaml index fadb78b9..df9987d9 100644 --- a/markup/toc.yaml +++ b/markup/toc.yaml @@ -53,3 +53,4 @@ sections: functions/form: "form_*()" functions/html: "html()" functions/dump: "dump()" + functions/url: "url_*()"