Twig url() function returns CP path when called from plugin 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-&gt;template-&gt;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.
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().)