Comments (5)
@jasonvarga thanks for getting back to me.
We have two collections on our website. The main difference between the two is the URL. We are using separate URLs for different targeting campaigns (short urls for print campaigns, longer urls for Adwords, for example).
The canonical tag is essential to make sure the two pages are not treated as duplicate content.
Adding a canonical tag to a singular page (which is how it works now) does not really add value. The exact reason for the canonical tag is to refer to other pages so that the page which is being referred to can be treated as the original source.
This is a pretty common SEO case, so I believe it would probably be best to expose the controls for this property in the SEO tab in the CP.
For now, we have created our own hotfix by creating our own Seo tag that extends SeoProTags
as follows:
class SeoTags extends SeoProTags
{
public function meta()
{
if (array_get($this->context, 'seo') === false) {
return;
}
$data = (new TagData)
->with(Settings::load()->get('defaults'))
->with(array_get($this->context, 'seo', []))
->withCurrent(array_get($this->context, 'page_object'))
->get();
// If this variable is set to true, the template will know that we're dealing with an override.
$data['canonical'] = false;
$canonical = $this->getParam('canonical');
if ($canonical !== null) {
$data['canonical'] = true;
$canonicalEntry = Entry::find($canonical);
if ($canonicalEntry) {
$data['canonical_url'] = $canonicalEntry->absoluteUrl();
}
}
return $this->render('meta', $data);
}
}
Our non-canonical pages have a collection field in which the UUID of the canonical page is stored, so we call it like this: {{ seo:meta canonical=parent }}
.
In our own meta.html
we have made adjustments so that the canonical tag is only added when it is actually set and different from the current page URL as follows:
{{ if canonical_url && canonical }}
<link href="{{ canonical_url }}" rel="canonical" />
{{ /if }}
from seo-pro.
Can I at least disable the canonical URL feature in SEO Pro so I can build my own?
Here's our issue: we have some blog articles that have been turned into documentation pages. If people google the content, we want Google to know that the documentation page is the correct page, but redirecting the blog article would be a jarring user experience.
There's also the occasional cross-posted blog article where a partner may author an article that we also want to include on our site, but we want google to know the original copy is the canonical version.
So really, in some cases just redirecting the page makes the most sense, but sometimes setting the canonical URL is the best experience for the user.
from seo-pro.
They're already set automatically based on your Permalink.
from seo-pro.
@jackmcdade we're experiencing issues with this as well. Isn't the idea of canonical urls to be able to set them to something different than the current permalink?
We have tried overriding the values, but there currently does not seem to be a way to do this because TagData.php
will simply set it to the absolute URL again.
Possible solutions would be:
- allow the tag to accept context, that is automatically merged in
TagData.php
Example:
{{ seo_pro:meta canonical_url='/foo' }}
- allow the canonical URL to be set through the CP, just like the title and description can be set. This seems to be the best solution.
Would love to hear your thoughts on this, because as it is now, the canonical URL functionality is not really usable. If I am overlooking something, I'd very much like to hear it too.
Thanks.
from seo-pro.
Can you explain in more detail why you are trying to set the canonical URL to something else? Do you mean you want to do it on a couple of pages or for the entire site?
from seo-pro.
Related Issues (20)
- Site and Alternate Locales broken in v5.2 HOT 2
- Error in Documentation or Bug with Antlers Code as Description HOT 8
- SiteDefaults are not localizable HOT 4
- Add missing markup to fix Google Search Console Error HOT 3
- Feature request: more control over sitemap content HOT 1
- Support paginated urls in sitemap.xml
- Front end cookies HOT 1
- Link rel='alternate' tags hreflang does not include language and locale HOT 7
- Social image from an Assets field (with multiple images) creating output of multiple social images HOT 1
- What is the correct syntax for using "From Field"?
- Improve support for custom route/controller page implementations HOT 1
- I get a "Vite manifest not found" error after installing the addon HOT 1
- What is the latest version that supports Statamic 3? HOT 2
- Wrong display in live preview
- Error ·Closure (Chunk.php:51) HOT 2
- Multisite Sitemap Support in SEO Pro HOT 1
- SEO Report shows duplicate title for pages in Multisite setup
- «Read only» visibility for Seo Pro fieldtype is not working / a.k.a hide Seo Pro fieldtype for editors
- False warning: pages with duplicate titles HOT 8
- Use same value for og:title as <title> tag
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seo-pro.