A universal solution: works from anywhere, not only from a template: /** @var \Magento\Framework\UrlInterface $urlInterface */ $urlInterface = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\UrlInterface'); $urlInterface->getUrl($path);