您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PageAdmin自助建站系统生成百度SiteMap的方

2019/11/8 3:24:05发布74次查看

pageadmin cms作为一款优秀的自助建站系统,国内拥有不少的用户,之前在论坛里看到很多用户生成百度sitemap文件都是通过安装插件来实现,但实际上通过系统自带的自定义路由功能一样可以实现sitemap文件生成,下面说一下步骤。
1、首先添加一个自定义路由的配置行,如何添加自定义路由,请参考我之前的文章,或者到官方帮助中搜索:自定义页面,可以找到自定义路由的使用方法,下面是我添加的一个配置行。
以上配置仅供参考,大家可以根据自己需要来写。
2、在模板目录的views目录下新一个sitemap/sitemap.cshtml文件,文件内容如下;
@{
layout = null;
string table = request.querystring[table];
string domain = http://localhost:800/buildsitemap.cshtml;//localhost:800改为您的网站域名,必须是外网域名
//生成栏目sitemap
if (table==column)
{
@foreach (var item in html.getcolumnlist().where(c => c.show == 1 && c.columntype <= 2))
{
string url = html.columnurl((int)(item.id));
@url
@datetime.now.tostring(yyyy-mm-dd)
weekly
0.8
}
}
//生成信息表的sitemap
else if (!string.isnullorempty(table))
{
@foreach (var item in html.infodatalist(new { table = table, shownumber = 1500 }))
{
http://www.pageadmin.net/jianzhan/@(item.id).cshtml
@item.thedate.tostring(yyyy-mm-dd)
weekly
0.5
}
}
else
{
httprequesthelper httprequesthelper = new httprequesthelper();
//生成栏目sitemap文件
iohelper.createfile(/columnsitemap.xml, httprequesthelper.get(domain+?table=column).trim(), true);
//生成product表的sitemap文件,必须保证news信息表实际存在
iohelper.createfile(/productsitemap.xml, httprequesthelper.get(domain+?table=product).trim(), true);
//生成news表的sitemap文件,必须保证news信息表实际存
存在
iohelper.createfile(/newssitemap.xml, httprequesthelper.get(domain+?table=news).trim(), true);
//更多信息表可以自行添加iohelper.createfile方法,table参数改为信息表名即可
response.write(sitemap文件生成成功!);
}
}
3、最后直接在浏览器中输入:您的域名/buildsitemap.cshtml 就会自动生成对应sitemap.xml文件。
生成完毕后可以到百度站长工具提交所有的sitemap文件的路径即可,以上是本人使用pageadmin cms系统的一些经验总结,希望对大家有帮助。

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product