I'm using Postmaster plugin to handle my e-mails using a custom service for SendGrid. In my templates I use Twig's url() function to create my URLs.

When they are sent by Postmaster, craft->template->render() method creates a Control Panel url instead of a normal front-end URL. Which results in URL's not found when clicked in the e-mail.

Is this normal behaviour when the render() method is called from the control panel? Or can I override this in Twig templating maybe? The Craft docs don't mention it.

In the meantime I can create my URL's using {{ siteUrl }}, but I'm wondering if I'm missing something here.

1 Answer 1


Right, url() (and UrlHelper::getUrl(), which url() maps to) will create a URL to either a front-end page or a CP page, depending on where it is being called from.

If you want to get a front-end URL from a CP request, you can use siteUrl() instead. (You can also get a CP URL from a front-end request via cpUrl().)

  • Nice! Didn't know that, works perfectly. Thanks Brandon!
    – ctigelaar
    Feb 3, 2016 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.