<p>So you can't just change the type of the <code>mainEntityOfPage</code> because there's a unique PHP class for each schema.org type.</p>
<p>What I would typically recommend here is that you set up the mappings via Content SEO (which lets you set up a different <code>mainEntityOfPage</code> per entry type) or you use the SEO Settings field to allow for per-entry changing of the <code>mainEntityOfPage</code>.</p>
<p>But if you really want to do it dynamically via Twig, you can. You just need to create a <em>new</em> object.</p>
<pre><code>{% do seomatic.jsonLd.create({
    'key': 'mainEntityOfPage',
    'type': 'Whatever',
{# fill in other properties here #}
}) %}
</code></pre>

CC BY-SA 4.0
2021-03-18T14:59:14.350Z
aaah, providing the key does the trick. thanks!
Matthias Redl-Mann
CC BY-SA 4.0
2021-03-18T13:04:24.280Z
2021-03-18T14:58:47.003Z
2021-03-18T14:58:47.003Z
andrew.welch
<p>With SEOmatic I want to be able to dynamically change the type of my mainEntity, which defaults to &quot;Webpage&quot; and in some cases I want to change it to &quot;Event&quot;</p>
<p>In an older project I did this:</p>
<pre><code>{% do seomatic.jsonLd.get('mainEntityOfPage').type('Event') %}
</code></pre>
<p>But if I dump the mainEntity again, nothing has changed:</p>
<pre><code>{% dd seomatic.jsonLd.get('mainEntityOfPage') %}
</code></pre>
<p>It's still a <code>nystudio107\seomatic\models\jsonld\WebPage#1</code></p>
<p>How can I achieve this?</p>
<p>I'm using Craft 3.4.30 with Seomatic 3.3.35</p>

<seomatic>
SEOmatic: Change type of mainEntity
# SEOmatic: Change type of mainEntity

(Asked by: username_0 on 2021-03-18)

With SEOmatic I want to be able to dynamically change the type of my mainEntity, which defaults to "Webpage" and in some cases I want to change it to "Event"
In an older project I did this:
{% do seomatic.jsonLd.get('mainEntityOfPage').type('Event') %}

But if I dump the mainEntity again, nothing has changed:
{% dd seomatic.jsonLd.get('mainEntityOfPage') %}

It's still a nystudio107\seomatic\models\jsonld\WebPage#1
How can I achieve this?
I'm using Craft 3.4.30 with Seomatic 3.3.35

**Tags:** seomatic

---

## 1 answers

### Answer by username_1 on 2021-03-18. Score: 3 | Accepted answer

So you can't just change the type of the mainEntityOfPage because there's a unique PHP class for each schema.org type.
What I would typically recommend here is that you set up the mappings via Content SEO (which lets you set up a different mainEntityOfPage per entry type) or you use the SEO Settings field to allow for per-entry changing of the mainEntityOfPage.
But if you really want to do it dynamically via Twig, you can. You just need to create a new object.
{% do seomatic.jsonLd.create({
    'key': 'mainEntityOfPage',
    'type': 'Whatever',
{# fill in other properties here #}
}) %}

> **Comments:**
> **username_0**: aaah, providing the key does the trick. thanks!  

---

