Answers.Body: <p>You can use a Twig <code>replace</code> filter in the email template to replace the URL with whatever you like. (I'm using this method myself because we have a similar problem on multi-site installs). To do this you'll need to be using custom templates for all system emails: <code>Settings &gt; Email &gt; HTML Email Template</code></p>
  
  <p>I'd set that to something like <code>emails/index</code>, which could then be like this, routing out to separate template files depending on the <code>emailKey</code>:</p>
  
  <pre><code>{# Craft has four predefined email keys:
  
      account_activation
      verify_new_email
      forgot_password
      test_email
  
  ... route to them here, or fallback to default
  #}
  
  {% include [
      'emails/' ~ emailKey ?? null,
      'emails/default'
  ] %}
  </code></pre>
  
  <p>Then <code>emails/account_activation.twig</code> could be something like this using the replace filter on the <code>link</code> variable: </p>
  
  <pre><code>{% extends 'emails/_emailLayout' %}
  
  {% set lockscreenText = 'Activate your account' %}
  
  {%- set heading -%}
      Hi {{ user.friendlyName ?? 'there' }},
  {%- endset -%}
  
  {% block content %}
      &lt;p&gt;Your account is now set up and ready to use, with your email address as your username.&lt;/p&gt;
      &lt;p&gt;To activate your account, click the following link:&lt;/p&gt;
  {% endblock %}
  
  {% if link is not defined %}
      {% set link = 'http://local.test' %}
  {% endif %}
  {% set buttonLink = link|replace('https://old.com/actions','https://new.com/actions') %}
  {% set buttonText = 'Activate your account' %}
  </code></pre>
  
  <p>...while <code>emails/_emailLayout</code> would have all the complicated mess of HTML that cross-client email requires.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T12:30:01.910Z
Answers.LastActivityDate: 2020-03-09T12:30:01.910Z
Answers.UserDisplayName: James Smith
Body: <p>I am using Craft as a headless CMS and have set base Url/siteUrl to the url of my React/Gatsby site.</p>
  
  <p>I needed to do this as my navigation plugin, <a href="https://github.com/dutchheight/craft-navie" rel="nofollow noreferrer">Navie</a>, appends it by default.</p>
  
  <p>But now when users registers, they are sent an activation email with the Gatsby url.</p>
  
  <p>How can I change this?</p>
  
  <p>Thanks</p>
  
Tags: <craft3><plugins><users><emails><navigation>
Title: Change base URL for email activation link?
ThreadText: # Change base URL for email activation link?
  
  (Asked by: username_0 on 2020-03-09)
  
  I am using Craft as a headless CMS and have set base Url/siteUrl to the url of my React/Gatsby site.
  
  I needed to do this as my navigation plugin, [Navie](https://github.com/dutchheight/craft-navie), appends it by default.
  
  But now when users registers, they are sent an activation email with the Gatsby url.
  
  How can I change this?
  
  Thanks
  
  **Tags:** craft3, plugins, users, emails, navigation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-03-09. Score: 2
  
  You can use a Twig `replace` filter in the email template to replace the URL with whatever you like. (I'm using this method myself because we have a similar problem on multi-site installs). To do this you'll need to be using custom templates for all system emails: `Settings > Email > HTML Email Template`
  
  I'd set that to something like `emails/index`, which could then be like this, routing out to separate template files depending on the `emailKey`:
  
  ```
  {# Craft has four predefined email keys:
  
      account_activation
      verify_new_email
      forgot_password
      test_email
  
  ... route to them here, or fallback to default
  #}
  
  {% include [
      'emails/' ~ emailKey ?? null,
      'emails/default'
  ] %}
  
  ```
  
  Then `emails/account_activation.twig` could be something like this using the replace filter on the `link` variable:
  
  ```
  {% extends 'emails/_emailLayout' %}
  
  {% set lockscreenText = 'Activate your account' %}
  
  {%- set heading -%}
      Hi {{ user.friendlyName ?? 'there' }},
  {%- endset -%}
  
  {% block content %}
      <p>Your account is now set up and ready to use, with your email address as your username.</p>
      <p>To activate your account, click the following link:</p>
  {% endblock %}
  
  {% if link is not defined %}
      {% set link = 'http://local.test' %}
  {% endif %}
  {% set buttonLink = link|replace('https://old.com/actions','https://new.com/actions') %}
  {% set buttonText = 'Activate your account' %}
  
  ```
  
  ...while `emails/_emailLayout` would have all the complicated mess of HTML that cross-client email requires.
  
  
  ---
  
  