Edit on GitHub
Jump to docs navigation

Twig Components / Methods / relative_path

relative_path(path) is a Twig function to return the relative path from the passed absolute URL.

For example, assume you’re on the following page in your app: http://example.com/products/hover-board.

{{ relative_path('http://example.com/human.txt') }}
{# ../human.txt #}

{{ relative_path('http://example.com/products/products_icon.png') }}
{# products_icon.png #}

Source: Symfony

Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.