Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Sitemap.xml for KooBoo site
ella
#1 Posted : Tuesday, February 21, 2012 7:05:56 PM(UTC)
Rank: Advanced Member
ella
Groups: Registered

Joined: 6/30/2011(UTC)
Posts: 57
Location: Russia
Hello.
I generate sitemap.xml for my site. Advise me, please, where I must put it - in root of Kooboo project, or site folder?
And whether KooBoo can autogenerate a sitemap file for my sites?
Thank you.
jifeng
#2 Posted : Wednesday, February 22, 2012 1:22:57 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,555
Location: Xiamen China
HI ella:

You please create a page call "sitemap.xml", then write the content or dynamic code to generate the content in the layout.
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
ella
#3 Posted : Wednesday, February 22, 2012 7:30:26 AM(UTC)
Rank: Advanced Member
ella
Groups: Registered

Joined: 6/30/2011(UTC)
Posts: 57
Location: Russia
I did as you say. It works fine. Thanks :)
sbrickey
#4 Posted : Thursday, February 23, 2012 1:03:52 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 12/16/2011(UTC)
Posts: 35
Location: Ohio, USA
Do you manage the sitemap file yourself, or is it dynamically generated? if it's dynamically generated, would you mind posting a copy of your code? (here or on the wiki)

Thanks :)
ella
#5 Posted : Monday, February 27, 2012 11:01:30 AM(UTC)
Rank: Advanced Member
ella
Groups: Registered

Joined: 6/30/2011(UTC)
Posts: 57
Location: Russia
I created a layout, for example with name - "layout for sitemap", and I included to its main code of sitemap.xml and one position for some content:
Quote:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/...9/sitemap.xsd">
<url>
<loc>http://kooboo-cms.ru/</loc>
<changefreq>daily</changefreq>
<priority>1.00</priority>
</url>
....
@Html.FrontHtml().Position("sitemap_content")
</urlset>


Then I created view for my content like this:
Quote:
@foreach (var item in ViewBag.categorylist){
<url>
<loc>http://kooboo-cms.ru/articles/@item.UserKey.ToLower()/</loc>
<changefreq>daily</changefreq>
<priority>0.80</priority>
</url>
}


Then I created the page called "sitemap.xml" based on layout ("layout for sitemap") and placed my view in that Position("sitemap_content").
2 users thanked ella for this useful post.
sbrickey on 2/27/2012(UTC), PetrAlexeev on 3/7/2012(UTC)
PetrAlexeev
#6 Posted : Wednesday, March 07, 2012 1:46:51 PM(UTC)
Rank: Member
Groups: Registered

Joined: 1/21/2012(UTC)
Posts: 25
Location: Turku, Finland
Thank you Ella!

I made it in a similar way.
1. I created a view "Article.Sitemap" to enumerate all articles in my site. This is source code of a view:
Code:

@{
  string baseUri = String.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
  if (ViewBag.Articles != null) {
    foreach (var item in ViewBag.Articles) {
<url>
  <loc>@baseUri@Url.FrontUrl().PageUrl("Article/Detail", new { UserKey = item.UserKey })</loc>
  <changefreq>weekly</changefreq>
  <priority>0.80</priority>
</url>
    }
  }
}


2. I added DataRule "Articles" to view "Article.Sitemap". This DataRule just contains unfiltered list of articles in my site. This list could be sorted. I also recommend to limit maximum number of items in this list to prevent resulting sitemap.xml file size increase over limit. Some search engines enforce limits to sitemap.xml.

3. I created layout "SiteMap" with following contents:
Code:

@{
    string baseUri = String.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
    Response.ContentType = "application/xml";
}
<?xml version="1.0" encoding="UTF-8"?>
<urlset
 xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
  <loc>@baseUri</loc>
  <changefreq>weekly</changefreq>
  <priority>1.00</priority>
</url>
<url>
  <loc>@baseUri@Url.FrontUrl().PageUrl("Tip")</loc>
  <changefreq>weekly</changefreq>
  <priority>0.80</priority>
</url>
<url>
  <loc>@baseUri@Url.FrontUrl().PageUrl("About")</loc>
  <changefreq>monthly</changefreq>
  <priority>0.80</priority>
</url>
@Html.FrontHtml().RenderView("Article.Sitemap",ViewData)
</urlset>


It's important to change MIME type by code Response.ContentType = "application/xml"; because resulting file should be treated as XML, but not as HTML. Also using baseUri variable is useful for adopting for other sites.

Line @Html.FrontHtml().RenderView("Article.Sitemap",ViewData) is a place for adding view "Article.Sitemap" created at step 1. It's easy to create this line by using Kooboo's Code helper in layout editor.

4. I created page "sitemap.xml" based on layout "SiteMap". I do not recommend to show this page in menu :).

Result is valid xml, that I cheched by various online validators like http://sitemapxml.net/sitemap-validator.php.

P.S. Thank you for http://kooboo-cms.ru! Congratulations on International Women's Day! :)
Petr Alexeev
MVP
1 user thanked PetrAlexeev for this useful post.
ella on 3/7/2012(UTC)
ella
#7 Posted : Wednesday, March 07, 2012 3:18:37 PM(UTC)
Rank: Advanced Member
ella
Groups: Registered

Joined: 6/30/2011(UTC)
Posts: 57
Location: Russia
Thank you for very good advice about "Response.ContentType", I didn't know it. And your sample is more useful and universal.

PetrAlexeev;5790 wrote:
Congratulations on International Women's Day! :)

Thanks! ;)

PetrAlexeev;5790 wrote:
P.S. Thank you for http://kooboo-cms.ru!

You know russian language!?
PetrAlexeev
#8 Posted : Wednesday, March 07, 2012 8:32:05 PM(UTC)
Rank: Member
Groups: Registered

Joined: 1/21/2012(UTC)
Posts: 25
Location: Turku, Finland
I'm very glad to know that information submitted by me is useful for somebody!

Additionally I could recommend to visit http://www.sitemaps.org/protocol.html and http://blog.vkistudios.c...8/3/6/XML-Sitemap-Guide to know more about sitemaps.

RSS feed could be used as sitemap as well. From my point of view RSS is more extensible and flexible way of providing sitemaps, but it's submission is not supported by some popular search providers.

P.S. Russian is my mother tongue.
Petr Alexeev
MVP
jifeng
#9 Posted : Thursday, March 08, 2012 1:26:32 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,555
Location: Xiamen China
Thank both you!
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
jifeng
#10 Posted : Thursday, March 08, 2012 1:28:26 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,555
Location: Xiamen China
P.S: The site: http://kooboo-cms.ru is very cool!!!!
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.128 seconds.