nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
166 stars 71 forks source link

Saving entry does not automatically refresh metadata changes for that entry #1514

Closed sm9 closed 2 months ago

sm9 commented 2 months ago

I've noticed that if I update the SEO metadata for an entry (after clicking the Override switch and editing the SEO Title Source and/or the SEO Description Source fields) via the SEO Settings fieldtype, then press Save for that entry, the changes aren't appearing on the front-end source code right away as expected when I refresh the web page.

Instead, I'm having to go to Utilities > Clear Caches, and clearing the caches in order to see the changes on the front-end source code. This means that clients are making lots of tweaks to the metadata, but they're not being seen on the front-end until the caches are cleared.

In SEOmatic > Plugin Settings > Advanced, I have the Meta Cache Duration field set to Unlimited, but I'd expect saving an entry to trigger an automatic refresh of this, in the same way that saving changes in other fields would automatically appear on the front-end after saving, whether Craft caching was enabled in the templates or not.

I also noticed that when making changes to other fields in the entry and pressing Save, the other field changes are appearing on the front-end, even when Craft caching is enabled for those those fields, but the SEOmatic metadata changes still isn't changing without manually clearing the caches.

I'm using Craft CMS 4.12.3, SEOmatic 4.1.3, and PHP 8.2.

Thanks in advance for any help with this one.

Stephen

khalwat commented 2 months ago

Yeah something doesn't sound right. Saving an entry will indeed clear the SEOmatic caches appropriately.

I'll see if I can reproduce this, but something sounds amiss here.

sm9 commented 2 months ago

Thanks Andrew. I am using native Craft caching in my template, where my custom fields are surrounded by the cache tags. But the main wrapper template has no cache tags so nothing in the head is cached (though the SEOmatic field is injected automatically anyway of course). Thanks, Stephen

khalwat commented 2 months ago

Think we can hop on a conference call where you can demonstrate the issue, and we can investigate it together?

I'm unable to replicate this locally.

https://savvycal.com/nystudio107/chat

sm9 commented 2 months ago

Hi Andrew, yes of course. I’ll arrange a call using that link, thanks.

In the meantime, in case it helps:

Look forward to catching you on that call, thanks.

khalwat commented 2 months ago

Only affecting the home page is an important bit of information. Do you have a single associated with the home page?

sm9 commented 2 months ago

Hi Andrew, yes, I have a "Home Page" single for the home page on both sites.

sm9 commented 2 months ago

Here's a screenshot of the settings for the Home page single: https://capture.dropbox.com/BsqlAwMqUAUB0t2M

khalwat commented 2 months ago

In your entry types, is the SEO Settings field just a regular field in the layout, or is it in some kind of embedded entry like in a Matrix block or nested entry or such?

khalwat commented 2 months ago

Also typically you'd set the settings for things like a homepage in Content SEO... you don't need to use an SEO Settings field unless content authors need to override the default mappings that you've set up for them.

sm9 commented 2 months ago

I am only using the Default Entry Type in the Home page single, and the SEO Settings field is a regular field (it’s not within a Matrix field). I do set the default settings in the Content SEO settings page of SEOmatic, but users like to override these defaults with custom titles and custom descriptions on the entry itself, like they do for other entries.

khalwat commented 2 months ago

Well, right you are. I found it, and fixed it in the above commits.

Craft CMS 3:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop as 3.5.3”,

Then do a composer clear-cache && composer update

…..

Craft CMS 4:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v4 as 4.1.3”,

Then do a composer clear-cache && composer update

…..

Craft CMS 5:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v5 as 5.1.3”,

Then do a composer clear-cache && composer update

sm9 commented 2 months ago

Hi Andrew, that's great, thanks for your patience in getting to the bottom of this as I was drip-feeding you the relevant information! :)

khalwat commented 2 months ago

Appreciate your help! Lmk how it works out for you. I was able to verify the bug and the fix locally.

sm9 commented 1 month ago

Hi Andrew, sorry for the delay in replying. I just upgraded to SEOmatic 5.1.4 and your fix has sorted this for me! Thanks again! :)

khalwat commented 1 month ago

Glad we got you sorted. Nice find!