<p>Like stated in the <a href="https://github.com/nystudio107/seomatic/wiki/02.-Rendering-your-SEO-Meta-tags" rel="nofollow noreferrer">docs</a> you can overwrite the default template with your own one and implement your logic however you like. So you can check for certain condition if you want to use the default SEOmatic inputs or your custom one. You can create a custom template based on this file <a href="https://github.com/nystudio107/seomatic/blob/master/templates/_seo_meta.twig" rel="nofollow noreferrer">meta template</a> and change <a href="https://github.com/nystudio107/seomatic/blob/master/templates/_seo_meta.twig#L19" rel="nofollow noreferrer">line 19</a>
from </p>

<pre><code>{% if seomaticMeta.canonicalUrl |length %}
&lt;link rel="canonical" href="{{ seomaticMeta.canonicalUrl }}" /&gt;
{% endif %}
</code></pre>

<p>to something like </p>

<pre><code>{% if entry.useCustomData is defined and entry.useCustomData == true%}
   &lt;link rel="canonical" href="{{ whatever }}" /&gt;
{% else %} 
    {% if seomaticMeta.canonicalUrl |length %}
        &lt;link rel="canonical" href="{{ seomaticMeta.canonicalUrl }}" /&gt;
    {% endif %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2018-01-05T14:27:48.973Z
Thanks very much for the answer! 

I've also been able to find more information in the docs about overriding the default data, and have created this in my layout template. 

`{% if entry.canonicalUrl|length > 0 %}  
{% set seomaticMeta = seomaticMeta | merge({'canonicalUrl': entry.canonicalUrl}) %}  
{% endif %}  
   
{% hook 'seomaticRender' %}`
David Ball
CC BY-SA 3.0
2018-01-05T15:08:12.093Z
Yes that is a really good approach as well, glad you found a solution
Robin Schambach
CC BY-SA 3.0
2018-01-05T14:13:54.477Z
2018-01-05T14:13:54.477Z
Robin Schambach
<p>Robin's answer above is valid, but I have managed to create an override in my main _layout template like this:</p>

<pre><code>{% if entry.canonicalUrl|length &gt; 0 %}
    {% set seomaticMeta = seomaticMeta | merge({'canonicalUrl': entry.canonicalUrl}) %}
{% endif %}

{% hook 'seomaticRender' %}
</code></pre>

CC BY-SA 3.0
2018-01-07T18:44:34.157Z
I prefer doing it this way
andrew.welch
CC BY-SA 3.0
2018-01-05T14:33:39.280Z
2018-01-05T14:33:39.280Z
David Ball
<p>SEOmatic puts a canonical on every page. But some pages I need to be able to add a custom canonical, but not sure how to overide SEOmatic's otherwise there will be two. </p>

<seo><plugin-seomatic>
Can I add a custom canonical URL to a page if also using SEOmatic?
# Can I add a custom canonical URL to a page if also using SEOmatic?

(Asked by: username_0 on 2018-01-05)

SEOmatic puts a canonical on every page. But some pages I need to be able to add a custom canonical, but not sure how to overide SEOmatic's otherwise there will be two.

**Tags:** seo, plugin-seomatic

---

## 2 answers

### Answer by username_1 on 2018-01-05. Score: 1 | Accepted answer

Like stated in the docs you can overwrite the default template with your own one and implement your logic however you like. So you can check for certain condition if you want to use the default SEOmatic inputs or your custom one. You can create a custom template based on this file meta template and change line 19
from 
{% if seomaticMeta.canonicalUrl |length %}

{% endif %}

to something like 
{% if entry.useCustomData is defined and entry.useCustomData == true%}
   
{% else %} 
    {% if seomaticMeta.canonicalUrl |length %}
        
    {% endif %}
{% endif %}

> **Comments:**
> **username_0**: Thanks very much for the answer!   I've also been able to find more information in the docs about overriding the default data, and have created this in my layout template.   `{% if entry.canonicalUrl|length > 0 %}   {% set seomaticMeta = seomaticMeta | merge({'canonicalUrl': entry.canonicalUrl}) %}   {% endif %}       {% hook 'seomaticRender' %}`  
> **username_1**: Yes that is a really good approach as well, glad you found a solution  

---

### Answer by username_0 on 2018-01-05. Score: 3

Robin's answer above is valid, but I have managed to create an override in my main _layout template like this:
{% if entry.canonicalUrl|length > 0 %}
    {% set seomaticMeta = seomaticMeta | merge({'canonicalUrl': entry.canonicalUrl}) %}
{% endif %}

{% hook 'seomaticRender' %}

> **Comments:**
> **username_2**: I prefer doing it this way  

---

