Home » Seach Engine Optimization » Programming SEO – Cross Linking Titles

Programming SEO – Cross Linking Titles


Here is another interesting way to programmatically add link juice to web pages from within your own site.  It will require that you have pages created dynamically from a database and that you have some way of retrieving the title.

You’ll remember that one of the ways of helping a page rank in the search engines is by providing links to that page that say what that page is about.  What better indication of what a page is about than the title?

So what you’ll need to do on each page is to gather a list of all the pages and their titles on your site, search for content on your page that matches each of those titles, and then hyperlink each phrase to the corresponding page on your site.

To do this, I’d recommend using regular expressions.

Given a title of “The Quick Brown Fox” you’d want to find any occurrence of that string that had any number of white space characters between the words and in any mix of casing.

The regular expression for that is:


So, for any title, you’d want to initialize your RegEx like this

Regex rx = new Regex(title.ToLower()
    .Replace(" ", @"\s+"),RegexOptions.IgnoreCase);

This assumes that there is only one space between each of the words in your title.

To replace the text in your article with a hyperlink using this text you’d use

body = rx.Replace(body,
    "<a href='locationOfTheArticleHere'>$0</a>");

This technique works best on page titles that are relatively short.  If your titles tend to be longer, as mine do, you might want to provide a list of possible linking phrases for each article.  In that case, I’d link to the titles first and then make a second pass for the linking terms if and only if a title was not found in the article.

The other obvious problem with this technique is that it could take a long time to generate the page if you have a lot of articles and you do this every time the page is displayed.  If this is the case, you’ll want to implement some caching mechanism either by using what is built into .NET or by using some other implementation that caches on a more permanent basis.


Other post in Seach Engine Optimization

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • Programming SEO – Cross LinkingProgramming SEO – Cross Linking As I mentioned a couple of weeks ago, cross-linking your pages within your site is one of the best ways I know to increase traffic to your site.  In fact, the week I added a plug-in […]
  • Google NOFOLLOW Change (and why this isn’t news)Google NOFOLLOW Change (and why this isn’t news) Or, Chicken Little and rel=nofollow Google recently admitted they have changed the way they pass page rank to pages from a page that has the nofollow attribute attached to one or more […]
  • Programming SEO – Tags and KeywordsProgramming SEO – Tags and Keywords Last week I started a series on SEO from a programming perspective.  Today we want to look at one of the topics I discussed in that post in a little more detail.  Tags. […]
  • DotNetNuke Tweak FOR SEODotNetNuke Tweak FOR SEO DotNetNuke does a pretty decent job of being optimized for the search engines.  But, while tweaking one of my sites today, I realized there is one place where there is room for […]
  • Programming SEO – PingProgramming SEO – Ping Now that we have an RSS feed we can use the feed to ping the various RSS directories that are available on the Internet.  This will create links back to your site including links back […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.

  • http://www.scottallender.com Scott Allender

    Nice! Interesting way to ensure consistency of links across a site.