|
Rank: Advanced Member Groups: Member
Joined: 12/23/2008 Posts: 42 Points: 126
|
Hi, We have recently been asked by our SEO company if we can change the url of our news articles to more friendly ones like the other pages within our Cuyahoga website. Rather than http://MyWebsite.aspx/79/section.aspx/46 it should be something like http://MyWebsite.aspx/articles/InsuranceArticleAre there any plans to introduce more SEO friendly article titles in the future? In not is anyone able to advise me on the best way of going about this? Many thanks
|
|
 Rank: Administration Groups: Administration
, Member
Joined: 12/30/2004 Posts: 1,674 Points: 1,824 Location: Wageningen (NL)
|
Yes, that's a good one. I've been looking to improve this for a while, but it's not easy. The point is that a page can contain multiple sections (modules), so we always have to supply the sectionid in the url, so that Cuyahoga knows which module is the active module. Let's say we have a page called /articles.aspx. To view a single article, we can't just add the title to the url like /articles/the-title-of-my-article.aspx, because there is no way that Cuyahoga can guess that we want to view the details of the article with title 'the-title-of-my-article' instead of a child page under articles.aspx.
A workaround might be to modify the articles module and add the title to the pathinfo like: http://mywebsite/79/section.aspx/46-the-title-of-my-article or http://mywebsite/79/section.aspx/the-title-of-my-article.
|
|
Rank: Administration Groups: Administration
, Member
Joined: 10/7/2008 Posts: 505 Points: 1,515
|
martijnb wrote: A workaround might be to modify the articles module and add the title to the pathinfo like: http://mywebsite/79/section.aspx/46-the-title-of-my-article or http://mywebsite/79/section.aspx/the-title-of-my-article.
Would that be difficult to implement? Either using the title of the article or adding an new SEOId which would be a unique string consisting of lower case a-z and 0-9 with maybe hyphens allowed? Using filtered input and validation to ensure formatting and uniqueness. That does sound good. I may have a look and a think.
|
|
 Rank: Administration Groups: Administration
, Member
Joined: 12/30/2004 Posts: 1,674 Points: 1,824 Location: Wageningen (NL)
|
I don't think it would be too difficult to implement. We already have a simple algorithm that creates the friendly url's when adding a new page, so perhaps you could borrow from that.
|
|
Rank: Advanced Member Groups: Member
Joined: 12/23/2008 Posts: 42 Points: 126
|
Ok I've sorted it in quite a simple way. In the rptArticles_ItemDataBound method of Articles.ascx.cs, I changed: string articleUrl = UrlHelper.GetUrlFromSection(this._module.Section) + "/" + article.Id; to string articleUrl = UrlHelper.GetUrlFromSection(this._module.Section) + "/" + article.Id + "/" + article.Title.Replace(" ","-"  ; This will give the SEO friendly url example of http://www.mywebsite.com/79/section.aspx/46/Article-About-Cuyahoga-stuff
|
|
Rank: Administration Groups: Administration
, Member
Joined: 10/7/2008 Posts: 505 Points: 1,515
|
jimmyfingers wrote:Ok I've sorted it in quite a simple way. In the rptArticles_ItemDataBound method of Articles.ascx.cs, I changed: string articleUrl = UrlHelper.GetUrlFromSection(this._module.Section) + "/" + article.Id; to string articleUrl = UrlHelper.GetUrlFromSection(this._module.Section) + "/" + article.Id + "/" + article.Title.Replace(" ","-"  ; This will give the SEO friendly url example of http://www.mywebsite.com/79/section.aspx/46/Article-About-Cuyahoga-stuff Cool, nice and quick. This can cause errors though with unsafe/reserved url characters. This may not be the best way but it works: Code://original// string articleUrl = UrlHelper.GetUrlFromSection(this._module.Section) + "/" + article.Id + "/";
string seoArticleUrl = UrlHelper.GetUrlFromSection(this._module.Section) + "/" + article.Id + "/" + article.Title.Replace(" ","-").ToLower(); // replace spaces with dashes seoArticleUrl = Regex.Replace(seoArticleUrl, "[^A-Za-z0-9-/._]", ""); // strip all illegal characters like punctuation string articleUrl = seoArticleUrl; Also regarding: martijnb wrote: We already have a simple algorithm that creates the friendly url's when adding a new page, so perhaps you could borrow from that. Can you point in general direction to where?
|
|
 Rank: Administration Groups: Administration
, Member
Joined: 12/30/2004 Posts: 1,674 Points: 1,824 Location: Wageningen (NL)
|
Constructor wrote:martijnb wrote: We already have a simple algorithm that creates the friendly url's when adding a new page, so perhaps you could borrow from that. Can you point in general direction to where? CreateShortDescription() in the Node class, but looking at your code example, you already found that one  .
|
|
Rank: Administration Groups: Administration
, Member
Joined: 10/7/2008 Posts: 505 Points: 1,515
|
martijnb wrote:Constructor wrote:martijnb wrote: We already have a simple algorithm that creates the friendly url's when adding a new page, so perhaps you could borrow from that. Can you point in general direction to where? CreateShortDescription() in the Node class, but looking at your code example, you already found that one  . That is remarkable. The code is almost identical. The code I posted was not from there!
|
|
 Rank: Administration Groups: Administration
, Member
Joined: 12/30/2004 Posts: 1,674 Points: 1,824 Location: Wageningen (NL)
|
Constructor wrote:martijnb wrote:Constructor wrote:martijnb wrote: We already have a simple algorithm that creates the friendly url's when adding a new page, so perhaps you could borrow from that. Can you point in general direction to where? CreateShortDescription() in the Node class, but looking at your code example, you already found that one  . That is remarkable. The code is almost identical. The code I posted was not from there! Well, then we probably used the same online example
|
|
Guest |