Improve DNN’s Page Priority


Improve Dotnetnuke Page Priority

DotNetNuke provides a Google-ready XML sitemap to help you get your pages indexed and ranked in Google search results.  Unfortunately, the current implementation sets every page's "priority" ranking to the same fixed value.  Because of this, no page ever gets priority over any other.  Fortunately there's a simple improvement you can make (using Notepad) to give priority to certain pages without changing any core DNN functions...

DNN SiteMap
As many of you are already aware, DNN provides an XML sitemap feature to help you get your portal(s) indexed on search engines.  An XML sitemap is more search-engine friendly than the easy-to-read (human-friendly) sitemaps.  In fact, the XML sitemap specification is now supported by a number of search engines including Google, Yahoo, MSN, Ask and more.  You'll therefore want to include a link on your website to the XML "SiteMap" even if you already have a separate human-friendly version available.

If you're not familiar with the DNN XML sitemap, you can view the map for any DNN portal by browsing to that portal's "sitemap.aspx" page:   http://(your URL)/sitemap.aspx 

Page Priority
If you look closely at the sitemap results, you'll see a field titled "priority".  The value inside of this field tells a search engine how important you consider that page to be.  Valid priority values range from "0.0" to "1.0".

Example:  Let's say you've created an online comic book.  You've linked together individual web pages with one web page per comic book page.  You probably consider the very first page of the comic to be more important than any other page in terms of search results.  That is, you probably would prefer to drive incoming visitors to the first page of the comic rather than have them land on some page in the middle of the comic.  If you divided your book into chapters, the first page of each chapter would also be given priority over other pages.  So you might give your site's homepage a priority value of "1.0", the starting page of the comic a value of "0.9", the starting pages of chapters a value of "0.8" and all other pages some value below "0.8".


DNN's Broken Page Priority

DNN assigns every page a priorty of "0.8" on a scale of "0.0" to "1.0".  This is not the result of "broken" functionality -- it's actually hard-coded that way.  As far as DNN site owners are concerned, however, it's "broken".  Until the DNN team addresses this point, the page priority value provides no benefit since no page ever gets priority over another.

What's needed is a way to influence page priority without changing core DNN code (changing core code is bad for a number of reasons).

Upgrading Your SiteMap
Fortunately the SiteMap is implemented as a standalone ASPX page rather than as a dynamically-created page as most other DNN portal pages are.  This means that we can alter the SiteMap code without changing any other DNN code.  Better still, we can easily backup our original sitemap files (there are only two files) under a different filename so they're readily available to switch back to if needed.  Even better, we can do it all with nothing more than Notepad.

Our simple upgrade will work as follows:
  • Every page gets a default priority value of "0.5".
  • If a DNN page has a DESCRIPTION set for it (defined under that page's SETTINGS), that page's priority value is increased by "0.1".
  • If a DNN page has any KEYWORDS set for it (defined under that page's SETTINGS), that page's priority value is increased by "0.1".
So, we can increase a particular page's priority by defining a description and/or by assigning keywords.  Are you already setting descriptions and keywords for all of your pages?  You're still in luck:  although this basic solution won't allow you to further increase page priority, it will have the happy result of decreasing priority for any pages with no content.  That is, menu tabs that exsist solely to provide menu links to child pages will get lower priority over the child pages that have actual content (assuming you did not assign descriptions and keywords to those empty pages).

Of course, there is nothing to stop you from further enhancing your site map to allow specific page prioritization -- we'll get into that near the end.

Steps for the Basic Site Map Upgrade:

1. Open "SiteMap.aspx.vb" with Notepad.  Select FILE->SAVE AS and save the file as "Original_SiteMap.aspx.vb".  (This is our backup copy of the codebehind file -- just in case!)  Close the file.

Open "SiteMap.aspx.vb" (again).

2. In the file "SiteMap.aspx.vb", find line 90.  (Hint:  Be sure you have VIEW->STATUS BAR active in Notepad so you can see what line and column the cursor is on.)
Line 90 should be:    Dim objTabs As New TabController

Immediately after line 90, insert this line:  Dim pagePriority As Single

3. Now find line 96.  It should be:  If intURLs < SITEMAP_MAXURLS Then

Immediately after line 96 insert this line:   pagePriority = 0.5

4. Now find line 103.  It should be:  sb.Append(BuildURL(URL, 2, pagePriority))

Replace line 103 with all of the following:

   If objTab.Description.Length > 0 Then
      pagePriority += 0.1
   End If
   If objTab.KeyWords.Length > 0 Then
      pagePriority += 0.1
   End If
   sb.Append(BuildURL(URL, 2, pagePriority))

5. Moving on, find line 121.  It sould be:
Private Function BuildURL(ByVal URL As String, ByVal Indent As Integer) As String

Replace line 121 with:

Private Function BuildURL(ByVal URL As String, ByVal Indent As Integer, ByVal pagePriority As Single) As String

6. Finally, locate line 129.  It should be:

sb.Append(WriteElement("priority", SITEMAP_PRIORITY, Indent + 1))

7. Replace line 129 with this:

sb.Append(WriteElement("priority", pagePriority, Indent + 1))

Save your file "SiteMap.aspx.vb".

That's it.  Test it out by broswing to the updated sitemp:

http://(your site's URL)/SiteMap.aspx


A NOTE ABOUT CACHE: If you've recently viewed your old sitemap file then the output may be cached on your web server  (you won't immediately see your changes).  You'll either have to recycle the web server (restart IIS on a Windows machine) or, in a hosted environment, wait until your host's cache expires.  An easy way around this (for testing purposes) is to append a unique querystring to your URL.  You'll have to give a new unique string for each view in order to avoid viewing a cached result.
Example:  For your first view, use   http://(your site's URL)/SiteMap.aspx?q=1
For your second view, use   http://(your site's URL)/SiteMap.aspx?q=2
...etc...

Getting Your SiteMap Searched
Once everything is just the way you like, be sure to add a link on your site's homepage (at the least) to the "SiteMap.aspx" page so it can get indexed by the various search engines.  Also, if you manually submit your site to a search engine for indexing, it's a good idea to also submit a direct link to the "SiteMap.aspx" page if specific page submissions are allowed.

You can find the full URL for your sitemap under the ADMIN settings.  For DNN versions 4.x, the URL is "fixed" to a specific path.  You don't have to use the "fixed" path and filename as specified by DNN but, if you use a different path and/or filename for your sitemap file, be sure to submit your actual sitemap URL to Google rather than the default URL as hard-coded in DNN.

To see DNN's default sitemap URL, browse to:

  ADMIN -> SITE SETTINGS

Look for the "Site Marketing" settings under "Basic Settings".  Find the "Site Map URL" value to see the full URL of your "SiteMap.aspx" file:

  
http://(your site's URL)/SiteMap.aspx

Taking Complete Control of Page Priority Values
Now that you know about the DNN SiteMap and have your own, standalone version to play with, you can expand what we've started and give yourself complete control over page priority values. How you do that is up to you, but one easy solution (without changing any core DNN code) would be to define your own "priority" token to include as part of your page's keywords.

Example:  Let's call our token "PPV" (Page Priority Value).  We can assign values simply by making them part of the token:

   Priority 0.0 = "PPV00", priority 0.5 = "PPV05", etc.

We'd then add appropriate code to "XMLSiteMap.aspx.vb" to parse the collection of keywords for a page, looking for any 5-character keywords beginning with "PPV".  We'd then set that page's priority by parsing the fourth and fifth characters and concatenating them into a single value of the form "x.y".  This value would override any default or derived priority value.

Hopefully the DNN team will soon add page priority features to the framework itself.  If not, perhaps I'll revisit this theme in the near future and implement the custom token feature I described.

Comments

Popular posts from this blog

SQL Server 2016 TDE ( Transparent Data Encryption)

Setting up Dotnetnuke (DNN) to work with Active Directory

Programming !!!!!!!!!!!