BullGuard Antivirus Sale - 60% Off with openElement !
Forum Home Forum Home >

openElement

> openElement General Discussion
  New Posts New Posts RSS Feed - Self referenceing Canonical rel [Solved]
  FAQ FAQ  Forum Search   Register Register  Login Login

Self referenceing Canonical rel [Solved]

 Post Reply Post Reply Page  12>
Author
Message
hunnypuppy View Drop Down
Newbie
Newbie


Joined: Aug 03 2023
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote hunnypuppy Quote  Post ReplyReply Direct Link To This Post Topic: Self referenceing Canonical rel [Solved]
    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.


Edited by Hobby001 - Dec 06 2023 at 7:38pm
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6208
Post Options Post Options   Thanks (1) Thanks(1)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post 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/” />



Edited by Hobby001 - Nov 19 2023 at 5:04pm
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6208
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: Nov 21 2023 at 6:48pm
@hunnypuppy

Any feed back on this topic?
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6208
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: Nov 24 2023 at 6:41pm
No feed back, closing topic
Back to Top
hunnypuppy View Drop Down
Newbie
Newbie


Joined: Aug 03 2023
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote hunnypuppy Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6208
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post 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 )


Back to Top
hunnypuppy View Drop Down
Newbie
Newbie


Joined: Aug 03 2023
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote hunnypuppy Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6208
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post 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.


Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6208
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: Nov 28 2023 at 12:16am
For more information on layers, https://denislafrance.net/index.en.php#formation
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6208
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post 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.




Edited by Hobby001 - Nov 28 2023 at 11:18am
Back to Top
 Post Reply Post Reply Page  12>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.