Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-18T14:59:14.350Z
Answers.Text: aaah, providing the key does the trick. thanks!
Answers.UserDisplayName: Matthias Redl-Mann
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-18T13:04:24.280Z
Answers.LastActivityDate: 2021-03-18T14:58:47.003Z
Answers.LastEditDate: 2021-03-18T14:58:47.003Z
Answers.UserDisplayName: andrew.welch
Body: <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>
  
Tags: <seomatic>
Title: SEOmatic: Change type of mainEntity
ThreadText: # 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!  
  
  ---
  
  