A few questions about canonical urls

Posted by Community Admin on 04-Aug-2018 15:10

A few questions about canonical urls

All Replies

Posted by Community Admin on 16-Jul-2015 00:00

Hello!

 I am trying to work on my first Sitefinity site - it was initially developed by a vendor and I'm trying to learn Sitefinity to make updates. (Just to let you know my experience level and, thus, how basic of a response I need.)

 Question/problem #1:

I've allowed canonical urls and they are showing up in the source of my pages, but they show as http:// and I would like them to show as https://. I can't seem to find a setting that would allow for this, but know I'm probably missing something. Can someone help me out?

 Question/Problem #2:

 ​The developers created some custom modules that work a bit like the default Sitefinity blog/news modules. Unlike them, however, I can't seem to find a way to get per entry canonical urls. For example:

 A category page onto which I've placed the module widget:

www.ufcu.org/.../establish-your-finances

 Article level pages:

www.ufcu.org/.../5-money-tips-for-new-graduates

www.ufcu.org/.../advice-for-graduating-college-students-looking-for-work

These all show the same canonical url in the source - that of the category page into which the custom news module has been dropped. Inside that widget, I don't have the options that exist in the standard blog widget that allow for the article urls to become the canonical url. My options are very limited (see attached screen grab) - I usually just change the category name so that the list view shows the posts from the category I want to show. 

 Does anyone have any advice or can point me to help on  how to get the canonical urls of the articles to, I guess, float up to the  main template and override the page url?

 Thanks!

Posted by Community Admin on 21-Jul-2015 00:00

Hello,

Regarding the first question. The url is retrieved from the Site URL settings. You can get more information about this in the "Configuring canonical URLs" section of our documentation article about enabling and disabling Canonical URLs service.

Regarding the second question. You seem to be missing the point of the canonical URLs. They serve to show the default page on which the item is displayed. Therefor all the articles on that page will have the same canonical URL. You can read further about the conception of canonical URLs in our documentation article here as well as in this article by google here.

Regards,
Velizar Bishurov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 21-Jul-2015 00:00

Perhaps I'm not explaining my problem properly, but I do understand the point of canonical URLs. They are to provide a single, always will work URL to a piece of content that might be accessible via multiple URLs. Essentially, multiple URLs might point to the same piece of content, but only one of those URLs is canonical. ​ Multiple pieces of content should not have the same canonical URL - which is what is happening on my site now. I need to know how to get the article/content URL up into the canonical URL field instead of the url for the page on which the widget is dropped. I'm just trying to get the custom modules to function like the default blog/news modules. 

 I've attached screen grabs of the settings mentioned in the documentation you linked to. What is set incorrectly? Why am I getting http in my canonical URLs and not https? I see no place to pick the default protocol (just the port).

Also, I'm still not getting consistent canonical urls no matter how I access the site. If I go with them or via a different subdomain, the canonical URLs change to the subdomain used instead of remaining www. I want the canonical URLs to remain the same no matter how the site is accessed - no matter the domain or subdomain used.

Posted by Community Admin on 24-Jul-2015 00:00

Hi Beth,

Judging by the screenshot from your first post the vendor has made you a custom widget that display your content items. By default Sitefinity does not recognize content displayed using custom widgets unless they implement the IContentLocatableView interface. You can read more about it in our documentation article about registering content location with custom widgets. This is why when you click on a particular article Sitefinity sets the canonical url to the actual page as it does not recognize that there is content there.

Regarding the https link can you please check that the page is set to require ssl. You can take a look at our documentation article about configuring SSL for how to do this.

Regards,
Velizar Bishurov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 05-Aug-2015 00:00

Thanks for the reply. I'm still trying to sort out how to perform the information in the first paragraph of you reply. 

 In regard to https showing on the canonical urls, the box you indicated I should uncheck in URL settings was already unchecked - and our canonical urls still start with http:// instead of https. Am a missing something in the setting screen? (see attachment)

Posted by Community Admin on 07-Aug-2015 00:00

Hi,

Regarding the content locations. Your custom widget needs to implement the "IContentLocatableView" interface in order for Sitefinity to set correct canonical url links. You can follow our documentation article about this.

Regarding the https. I was refering to the "Requries SSL" checkbox on the page's Title & Properties. You can check that by clicking more actions on the page, clicking Title & properties and scrolling to the advanced section.

Regards,
Velizar Bishurov
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 07-Aug-2015 00:00

Yes, I understand that you are pointing to a method I need to implement, but I'm not a Sitefinity developer, so I don't know where/how to try and implement that. I'm trying to learn and do appreciate you letting me know what I need to look at to accomplish this, but I still need to learn some stuff before I can get there.

 

Do you mean I have to go in and check that box on all of our pages one at a time? We have a lot of pages...

Posted by Community Admin on 13-Aug-2015 00:00

Any reply to the question about having to check the "Require SSL" box on every piece of content? Because that's not really an option for us as we then won't be able to sync content between our dev (non-SSL) and live (SSL) environments.

Posted by Community Admin on 14-Aug-2015 00:00

Hi,

You can use the following code on a web form's code-behind for example to set the Requires SSl property on all frontend pages programmatically. You can further filter the pages if needed.

var pageManager = PageManager.GetManager();
 
var pageNodes = pageManager.GetPageDataList()
    .Where(pd => pd.NavigationNode.RootNode == SiteInitializer.CurrentFrontendRootNodeId)
    .Select(pd => pd.NavigationNode);
 
foreach (PageNode pageNode in pageNodes)
    pageNode.RequireSsl = true;

Regards,
Velizar Bishurov
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 14-Aug-2015 00:00

Thanks. I guess I could look into switching based on domain so that it wouldn't require ssl on our development servers.

Posted by Community Admin on 11-Apr-2016 00:00

I am attempting to use this code but it does not actually save the changes at any point to the page.  If I try to call the SaveChanges then I get an error "Cannot use SaveChanges or CancelChanges on instance manager that was specified to use global or distributed transaction. Instead, use TransactionManager static methods CommitTransaction(string transactionName) or RollbackTransaction(string transactionName)."  How can I set all pages to requireSSL on site load?

 

PageManager pageManager = PageManager.GetManager(null, Guid.NewGuid().ToString());
            using (new ElevatedModeRegion(pageManager))
           
                var pageNodes = pageManager.GetPageDataList()
                    .Where(
                        pd =>
                            pd.NavigationNode.RootNode.Id == SiteInitializer.CurrentFrontendRootNodeId &&
                            !pd.NavigationNode.RequireSsl)
                    .Select(pd => pd.NavigationNode);
                foreach (PageNode pageNode in pageNodes)
               
                    pageNode.RequireSsl = true;
               
                pageManager.SaveChanges();
           

Posted by Community Admin on 14-Apr-2016 00:00

Hi,

The problem is that you are explicitly specifying a transaction name when getting the manager. Either use the GetManager method without the second parameter or save the new guid in a variable and use the following static method with the guid as parameter:

TransactionManager.CommitTransaction("GUID");

Regards,
Velizar Bishurov
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 14-Apr-2016 00:00

Thanks for replying - I figured that out after asking and should have updated.  I removed the parameters and savechanges worked fine.

This thread is closed