Print Page | Close Window

Self referenceing Canonical rel [Solved]

Printed From: openElement Website
Category:

openElement


Forum Name: openElement General Discussion
Forum Description: A place for general discussion and questions about the software.
URL: https://forums.openelement.uk/en/forum_posts.asp?TID=1983
Printed Date: Feb 27 2024 at 8:30pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Self referenceing Canonical rel [Solved]
Posted By: hunnypuppy
Subject: Self referenceing Canonical rel [Solved]
Date Posted: Nov 19 2023 at 1:57pm
Is there any way to configure open element to automatically include a self referencing Canonical rel link in the page header for each page?

If not, how does one do it?

Also, is there a way to automatically have the domain component of the Canonical rel inserted at runtime (e.g. if I'm using an IIS ASPX to host it) so that if the hosting domain changes the Canonical rel is still valid when the page is delivered by IIS.



Replies:
Posted By: Hobby001
Date Posted: Nov 19 2023 at 5:03pm
If you look on top of the working area, you have the current language button the the source code button.

Click on source code button a code edition screen will appear.

Click on the Plus sign, add a name for fututr reference, select Html, select Header

Add your preferred code like: 

<link rel=“canonical” href=“ https://example.com/sample-page/”" rel="nofollow - https://example.com/sample-page/” />

https://ahrefs.com/blog/canonical-tags/#canonical-tag-syntax" rel="nofollow - https://ahrefs.com/blog/canonical-tags/#canonical-tag-syntax


-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Hobby001
Date Posted: Nov 21 2023 at 6:48pm
@hunnypuppy

Any feed back on this topic?


-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Hobby001
Date Posted: Nov 24 2023 at 6:41pm
No feed back, closing topic

-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: hunnypuppy
Date Posted: Nov 27 2023 at 5:06pm
Sorry the delay, that was very helpful. This is what I finally ended up adding in the Header -> HTML code snippet for a ASP.NET server on the main landing page. This would automatically insert the domain ending with a / as the self referencing canonical.

<% string rootDomain = "\"" + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/\""; %>
<link rel="canonical" href=<%= rootDomain %> />

I would need to now modify this to include the page name for each page that I create through OpenElement for each page to have their own self referencing canonical link. The problem though is that if I change the name of the page I will need to remember to update the code snippet on the page.

It would be awesome if OpenElement can have an option automatically include the self referencing canonical code in the page header and then update it when the page name changes through OpenElement.


Posted By: Hobby001
Date Posted: Nov 27 2023 at 5:30pm
Of course it would be interresting.

You can automate it using javascript. 

Give me two examples of script ( two different pages )




-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: hunnypuppy
Date Posted: Nov 27 2023 at 8:20pm
Sorry I didn't understand what you're asking for. Are you asking me for a script? I don't have any.

I was just asking if it's possible to include a check box or option in the page setting to automatically include the canonical code based on the website address entered in openelement and then update that automatically when the page is renamed.


Posted By: Hobby001
Date Posted: Nov 27 2023 at 8:51pm
You can use a layer for that.

Let's assume that you are currently using the default Base layer in your project containing multiple pages

Second assumption, you do not want your script on every pages but on many of those.

Here is the solution

  • Create a new layer named canonical
  • Make sure that the base layer is assigned to it.
  • Add an html code block in the header position
  • In this code block add your script:
<% string rootDomain = "\"" + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/\""; %>
<link rel="canonical" href=<%= rootDomain %> />
  • Then on the pages that requires it, replace the Base layer with the canonical layer
It is not going to be a check box but a simple layer selection.

The reason to keep the base layer assigned to the canonical layer is to maintain any existing set-up previously made to the project troughout the base layer.




-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Hobby001
Date Posted: Nov 28 2023 at 12:16am
For more information on layers,  https://denislafrance.net/index.en.php#formation" rel="nofollow - https://denislafrance.net/index.en.php#formation

-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Hobby001
Date Posted: Nov 28 2023 at 10:59am
By the way, I an not familiar with ASP.net.

I needed to get more info on it to understand your script.  If you have any other question of this kind, explain your code so helping you will be easier.




-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Hobby001
Date Posted: Nov 29 2023 at 9:13pm
Any feed back on layer usage?

-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Hobby001
Date Posted: Dec 04 2023 at 9:13pm
Any progress?

-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video


Posted By: Hobby001
Date Posted: Dec 06 2023 at 7:38pm
No feed back from user closing topic

-------------
https://denislafrance.net/index.en.php" rel="nofollow - https://denislafrance.net https://www.youtube.com/playlist?list=PLWg7A6YtIr7WE2oJe9pX8_3u0FerqJwjo" rel="nofollow - , OE training video



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net