Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

og:url and twitter:url referencing Blitz cache token #457

Closed
icreatestuff opened this issue Aug 16, 2023 · 2 comments
Closed

og:url and twitter:url referencing Blitz cache token #457

icreatestuff opened this issue Aug 16, 2023 · 2 comments

Comments

@icreatestuff
Copy link
Contributor

Description

We have a site that uses Ether SEO and the full-page caching Blitz plugin.

When Bltz is generating the cache it adds a token parameter to the URL which is being saved to the og:url and twitter:url meta tags within the SEO meta template because they use {{ craft.app.request.absoluteUrl }}. Based on this discussion on the Blitz repo and the warning provided in the Craft 4 class reference docs for this method it seems this isn't recommended.

The result of having the ?token=... parameter cached to those SEO tags is that the canonical URL that Facebook and Twitter/X are using is incorrect and results in no preview data (title, image description etc) being pulled through.

Is there an alternative to {{ craft.app.request.absoluteUrl }} that can be used?

Thanks

Additional info

  • Craft version: Pro 4.4.17
  • SEO version: 4.1.2
  • PHP version: 8.2.8
  • Database driver & version: MySQL 8.0.34
  • Other Plugins: Blitz 4.5.1
@icreatestuff
Copy link
Contributor Author

For now, I've ended up using a custom SEO meta template so I can override those tags using this instead {{ url(craft.app.request.fullPath) }} to remove any query strings from the URL. If there's a more elegant approach or a way to only exclude the ?token parameter but retain any other params that may exist I'm all ears.

@Tam Tam closed this as completed in f2b657b Aug 18, 2023
@icreatestuff
Copy link
Contributor Author

Thanks for jumping on a fix for this so quickly @Tam really appreciated it.

It looks to be working pretty well for my use case so far, the only thing I'm wondering about is that my URLs are now left with a lonely ? at the end e.g. https://test-site.ddev.site/my-entry-page?. Is there a way to have that removed if there are no query string parameters left having removed the token parameter?

Thanks

@Tam Tam reopened this Aug 23, 2023
@Tam Tam closed this as completed in dc9fa7f Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants