{
  "path": "/articles/2024-seo-fields-4-update",
  "site": "at://did:plc:kq2tuvvnlen4jjcqiw4oprjm/site.standard.publication/3mhyhqc3kcaw7",
  "tags": [
    "Craft CMS"
  ],
  "$type": "site.standard.document",
  "title": "SEO Fields 4: Schema.org, automatic redirects & updated template functions",
  "content": {
    "html": "<div><h2>JSON-LD Schema.org support</h2><p>This release adds rendering of Schema.org data in JSON-LD format. You can set a Schema type for each section in your site, and the plugin will output structured data based on the type you selected and the meta fields you filled out in the plugin.</p>\n<p>You can also customize the schema that get's put on the page, like in the example below. Internally the plugin relies on  <a href=\"https://github.com/spatie/schema-org\">spatie/schema-org</a> to create these objects. You can find more documentation <a href=\"https://studioespresso.github.io/craft-seo-fields/schema.html\">here</a>.</p>\n</div><div><h2></h2><pre><code>{# This line should go before any layout you're extending #}\n{% do entry.setShouldRenderSchema(false) %}\n\n{# @var schema \\Spatie\\SchemaOrg\\Schema #}\n{% set schema = craft.schema %}\n{{ schema.organization\n    .name(\"Studio Espresso\")\n    .email(\"info@studioespresso.co\")\n|raw }}</code></pre></div><div><h2>Automatic redirects when a URI changes</h2><p>A smaller addition but something that is worth mentioning none the less: there now is a setting (enabled by default) that enables the creation of redirects automatically when the slug or uri changes for an entry.</p>\n</div><div><h2>Overwrite field values in Twig</h2><p>This is something that used to work in Craft 3 but that has been broken for some time. In order to fix it, I've had to move a bunch of things around and change a number of template functions - so I'm happy to say this is once again something you can do.</p>\n</div><div><h2>Upgrading to version 4</h2><p>If you're using the <code>entry.seo.set...</code> functions in your templates right now, be sure to read through the  documentation <a href=\"https://studioespresso.github.io/craft-seo-fields/templating.html#overwriting-field-values\">here</a> to ensure things don't break.</p>\n</div><div><h2>Updated documentation</h2><p>I'm excited for this large update as it contains a bunch of things I've been meaning to add for a long time and it brings the plugin to a good place to start the upgrade to Craft 5 from.</p><p>I hope you'll give it a try if you haven't before, and should you run into any issues - feel free to <a href=\"https://www.studioespresso.co/contact\">reach out to me</a> or to <a href=\"https://github.com/studioespresso/craft-seo-fields/issues\">create an issue on GitHub</a>.</p></div>",
    "$type": "org.wordpress.html"
  },
  "updatedAt": "2024-01-24T11:52:47+01:00",
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreifpxdibzj3fsdpyjm2x7q7ucjszkiedcvygaztg6btpfp2e2tsh7a"
    },
    "mimeType": "image/jpeg",
    "size": 646701
  },
  "description": "A big update for my SEO Fields plugin was just released and in this post I'd like to tell you a bit more about what was added, what was changed and what you need to check before upgrading.",
  "publishedAt": "2024-01-10T09:54:00+01:00",
  "textContent": "JSON-LD Schema.org supportThis release adds rendering of Schema.org data in JSON-LD format. You can set a Schema type for each section in your site, and the plugin will output structured data based on the type you selected and the meta fields you filled out in the plugin.\nYou can also customize the schema that get's put on the page, like in the example below. Internally the plugin relies on  spatie/schema-org to create these objects. You can find more documentation here.\n{# This line should go before any layout you're extending #}\n{% do entry.setShouldRenderSchema(false) %}\n\n{# @var schema \\Spatie\\SchemaOrg\\Schema #}\n{% set schema = craft.schema %}\n{{ schema.organization\n    .name(\"Studio Espresso\")\n    .email(\"info@studioespresso.co\")\n|raw }}Automatic redirects when a URI changesA smaller addition but something that is worth mentioning none the less: there now is a setting (enabled by default) that enables the creation of redirects automatically when the slug or uri changes for an entry.\nOverwrite field values in TwigThis is something that used to work in Craft 3 but that has been broken for some time. In order to fix it, I've had to move a bunch of things around and change a number of template functions - so I'm happy to say this is once again something you can do.\nUpgrading to version 4If you're using the entry.seo.set... functions in your templates right now, be sure to read through the  documentation here to ensure things don't break.\nUpdated documentationI'm excited for this large update as it contains a bunch of things I've been meaning to add for a long time and it brings the plugin to a good place to start the upgrade to Craft 5 from.I hope you'll give it a try if you haven't before, and should you run into any issues - feel free to reach out to me or to create an issue on GitHub."
}