搜索引擎优化(SEO)的目的就是尝试让网站页面在搜索引擎结果中尽可能高。当然这也是有争议的:对它的支持者来说,这是获取网络流量必不可少的方式,而对它的批评者来说,往好了说,这是俗气的,往坏了说,这是小贩、垃圾邮件发送者和骗子的领域。尽管如此,对于那些运营公共维基的人来说,在搜索结果中排名靠前是很重要的。
首先,MediaWiki在搜索结果方面已经做得很好了。维基百科是基于MediaWiki的,它是搜索结果中表现最好的网站,无论以什么标准衡量:它通常是前三名,而且经常是关于它所涵盖的任何主题的搜索的第一名。这主要是因为它经常从其他网站链接到这些特定主题,但也有部分原因是MediaWiki自己的设计。
结合网上的信息和自己在建站过程中的有限经验,梳理了以下几条。

一、重写网站的URL的形式

其实就是MediaWiki的短链,如果刚安装完没有进行任何配置,通常我们打开的站点链接应该是这样的:

yourwiki.com/index.php?title=首页

或者是

yourwiki.com/index.php/首页

总之,看上去非常别扭。
所以,我们要做的就是改成yourwiki.com/wiki/首页yourwiki.com/w/首页或者是yourwiki.com/首页(前两种是官方推荐的,最后一种是我目前在使用的,暂时也没有发现任何大问题)。
具体操作的话,可以参考本站的文章《Mediawiki短链(Short URL)设置》,这里就不再赘述了。

二、为站点创建sitemap

Sitemap 可方便网站管理员通知搜索引擎,他们网站上有哪些可供抓取的网页。

原理之类的就不多介绍了,其目的就是让爬虫爬取网站内容节省时间,让爬虫对网站的结构有整体的认识。
如何生成的话,可以通过某些在线站点进行,也可以通过MediaWiki的维护脚本或插件进行,具体参见本站文章《为MediaWiki站点创建网站地图(sitemap)

三、自定义MediaWiki的robots.txt文件
默认情况下,MediaWiki有一些实用工具页面(如特殊页面等),这些页面不会对搜索引擎隐藏。使用robots.txt文件可以隐藏这些内容,避免被搜索引擎收录。比如:

User-agent: *
Disallow: /index.php?title=Special:*
Disallow: /index.php?title=特殊:*
Disallow: /index.php?title=%E7%89%B9%E6%AE%8A:*
Disallow: /skins/

当然,如果你已经进行了短链设置,那么记得添加短链的形式

Disallow: /Special:*
Disallow: /特殊:*
Disallow: /%E7%89%B9%E6%AE%8A:*

具体方法参见官方网站中的手册,至于你想要让搜索引擎搜到啥由你自己决定。中文特殊:其实并不会被正确解读,还是需要转成字符形式,放在其中一来是为了自己看起来方便,而来也是为了保险,谁知道是不是所有的爬虫都不支持中文呢。

四、安装SEO扩展

这里只推荐一款扩展——WikiSEO,它添加了wiki页面HTML源代码的标记。它定义了一个名为“#seo”的解析器函数,可以将它添加到页面的任何地方,并按以下方式调用它:</p><pre><code>{{#seo: title=... | titlemode=... | keywords=... | description=... }} </code></pre><p>详细介绍和具体用法可参见本站文章《<a href="https://tech.mindseed.cn/MediaWiKi/950.html">MediaWiki的SEO扩展——WikiSEO</a>》。</p><h2>五、条目分类的层级关系</h2><p>这是为了增加页面之间的相关性,既方便读者浏览也能更好地进行站点的内部链接。要说对搜索引擎到底有多大用的话,我也不清楚。</p><h2>六、提交信息给各大搜索引擎</h2><p>最后就是去百度、谷歌、必应、搜狗等站点管理工具中提交你的站点信息。网上的教程一抓一大把,这里就不写了。</p><h2>总结</h2><p>说到底,其实还是内容最重要,否则再怎么优化,搜索引擎也不傻。</p></div> <!--文章的页脚部件:打赏和其他信息的输出--> <div class="show-foot"><div class="notebook" data-toggle="tooltip" data-original-title="2022 年 10 月 14 日 01 : 59 PM"> <i class="fontello fontello-clock-o"></i> <span>最后修改:2022 年 10 月 14 日</span> </div><div class="copyright" data-toggle="tooltip" data-html="true" data-original-title="转载请保留本文转载地址,著作权归作者所有"><span>© 允许规范转载</span> </div> </div> <!--打赏模块--> <div class="support-author"> <button id="support_author" data-toggle="modal" data-target="#myModal" class="box-shadow-wrap-lg btn_post_footer btn btn-pay btn-yellow btn-rounded"><svg fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true"><path d="M10.084 7.606c3.375-1.65 7.65-1.154 10.493 1.487 3.497 3.25 3.497 8.519 0 11.77-3.498 3.25-9.167 3.25-12.665 0-.897-.834-2.488-2.96-2.488-5.085" stroke="currentColor" stroke-width="1.4" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path><path d="M17.392 14.78s1.532-1.318-.053-2.79c-1.585-1.473-3.17-.404-3.719.403-.549.807.495 2.082.93 2.69.434.61 1.364 2.182-.054 3.202-1.417 1.012-3.002.658-4.153-.708-1.15-1.367-.602-3.365 0-3.924M17.338 11.982l1.159-1.076M9.87 18.922l.937-.871" stroke="currentColor" stroke-width="1.4" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path><path d="M.8 1.205s7.15 4.673 8.773 6.182c1.623 1.508 3.231 4.008 1.616 5.509-2.195 2.04-4.054.595-6.737-.75-.884-.447-3.15-1.777-3.15-1.777M10.136.9l1.047 3.188" stroke="currentColor" stroke-width="1.4" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path></svg><span>打赏</span></button> <div id="myModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"> <div class="modal-dialog modal-sm" role="document"> <div class="modal-content box-shadow-wrap-lg"> <div class="modal-header box-shadow-bottom-normal"> <button type="button" class="close" data-dismiss="modal"><i style="vertical-align: bottom;" data-feather="x-circle"></i></button> <h4 class="modal-title">赞赏作者</h4> </div> <div class="modal-body"> <div class="solid-tab tab-container post_tab"> <ul class="nav no-padder b-b scroll-hide" role="tablist"> <li class="nav-item active" role="presentation"><a class="nav-link active" style="" data-toggle="tab" role="tab" data-target="#alipay_author"><i class="iconfont icon-alipay" aria-hidden="true"></i>支付宝</a></li><li class="nav-item " role="presentation"><a class="nav-link " style="" data-toggle="tab" role="tab" data-target="#wechatpay_author"><i class="iconfont icon-wechatpay" aria-hidden="true"></i>微信</a></li> </ul> <div class="tab-content no-border"><div role="tabpanel" id="alipay_author" class="tab-pane fade active in"> <img noGallery class="pay-img tab-pane" id="alipay_author" role="tabpanel" src="https://tech.mindseed.cn/usr/themes/handsome/assets/img/loading.svg" data-original="https://ms-blog.mindseed.cn/alipay.png" /> </div><div role="tabpanel" id="wechatpay_author" class="tab-pane fade "> <img noGallery class="pay-img tab-pane" id="wechatpay_author" role="tabpanel" src="https://tech.mindseed.cn/usr/themes/handsome/assets/img/loading.svg" data-original="https://ms-blog.mindseed.cn/wechart-pay.jpg" /> </div> </div><!--tab-content--> </div> <!--tab-container--></div> <!--modal-body--> </div><!--modal-content--> </div><!--modal-dialog--> </div><!--modal--> <button id="star_post" data-cid="949" class="box-shadow-wrap-lg btn_post_footer like_button btn btn-pay btn-rounded"> <svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="shake-little unlike_svg feather feather-thumbs-up"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"></path></svg> <div class="circle-rounded"></div> <svg class="liked_svg" style="transform: scale(2.2);" xmlns="http://www.w3.org/2000/svg" viewBox="30 30 60 60" width="60" height="60" preserveAspectRatio="xMidYMid meet"> <g clip-path="url(#__lottie_element_1061)"> <g style="display: block;" transform="matrix(1,-0.0000012433954452717444,0.0000012433954452717444,1,47.87498474121094,47.057003021240234)" opacity="1"> <g class="like_rotate"> <g opacity="1" transform="matrix(1,0,0,1,14.376999855041504,11.416000366210938)"> <path stroke-linecap="butt" stroke-linejoin="miter" fill-opacity="0" stroke-miterlimit="10" stroke="rgb(255,255,255)" stroke-opacity="1" stroke-width="2" d=" M-7.936999797821045,9.531000137329102 C-7.936999797821045,9.531000137329102 3.378000020980835,9.531000137329102 3.378000020980835,9.531000137329102 C3.815999984741211,9.531000137329102 4.209000110626221,9.258999824523926 4.360000133514404,8.847000122070312 C4.360000133514404,8.847000122070312 7.501999855041504,0.36000001430511475 7.501999855041504,0.36000001430511475 C8.020000457763672,-1.0360000133514404 6.986000061035156,-2.5199999809265137 5.497000217437744,-2.5199999809265137 C5.497000217437744,-2.5199999809265137 -0.5669999718666077,-2.5199999809265137 -0.5669999718666077,-2.5199999809265137 C-0.6399999856948853,-2.5199999809265137 -0.6859999895095825,-2.5969998836517334 -0.6499999761581421,-2.6600000858306885 C-0.36800000071525574,-3.1679999828338623 0.6269999742507935,-4.922999858856201 0.8870000243186951,-5.764999866485596 C1.309000015258789,-7.13100004196167 0.847000002861023,-8.715999603271484 -1.4539999961853027,-9.519000053405762 C-1.4759999513626099,-9.526000022888184 -1.4989999532699585,-9.527000427246094 -1.5180000066757202,-9.519000053405762 C-1.5299999713897705,-9.513999938964844 -1.5410000085830688,-9.505999565124512 -1.5490000247955322,-9.494000434875488 C-1.7309999465942383,-9.234999656677246 -2.6489999294281006,-7.934000015258789 -3.6419999599456787,-6.52400016784668 C-4.795000076293945,-4.888000011444092 -6.050000190734863,-3.1059999465942383 -6.380000114440918,-2.638000011444092 C-6.434000015258789,-2.562000036239624 -6.519000053405762,-2.5199999809265137 -6.611000061035156,-2.5199999809265137 C-6.611000061035156,-2.5199999809265137 -7.938000202178955,-2.5199999809265137 -7.938000202178955,-2.5199999809265137 C-7.982999801635742,-2.5199999809265137 -8.020000457763672,-2.4839999675750732 -8.020000457763672,-2.437999963760376 C-8.020000457763672,-2.437999963760376 -8.020000457763672,9.447999954223633 -8.020000457763672,9.447999954223633 C-8.020000457763672,9.494000434875488 -7.982999801635742,9.531000137329102 -7.936999797821045,9.531000137329102z"></path> <path fill="rgb(255,255,255)" fill-opacity="1" d=" M-7.936999797821045,9.531000137329102 C-7.936999797821045,9.531000137329102 3.378000020980835,9.531000137329102 3.378000020980835,9.531000137329102 C3.815999984741211,9.531000137329102 4.209000110626221,9.258999824523926 4.360000133514404,8.847000122070312 C4.360000133514404,8.847000122070312 7.501999855041504,0.36000001430511475 7.501999855041504,0.36000001430511475 C8.020000457763672,-1.0360000133514404 6.986000061035156,-2.5199999809265137 5.497000217437744,-2.5199999809265137 C5.497000217437744,-2.5199999809265137 -0.5669999718666077,-2.5199999809265137 -0.5669999718666077,-2.5199999809265137 C-0.6399999856948853,-2.5199999809265137 -0.6859999895095825,-2.5969998836517334 -0.6499999761581421,-2.6600000858306885 C-0.36800000071525574,-3.1679999828338623 0.6269999742507935,-4.922999858856201 0.8870000243186951,-5.764999866485596 C1.309000015258789,-7.13100004196167 0.847000002861023,-8.715999603271484 -1.4539999961853027,-9.519000053405762 C-1.4759999513626099,-9.526000022888184 -1.4989999532699585,-9.527000427246094 -1.5180000066757202,-9.519000053405762 C-1.5299999713897705,-9.513999938964844 -1.5410000085830688,-9.505999565124512 -1.5490000247955322,-9.494000434875488 C-1.7309999465942383,-9.234999656677246 -2.6489999294281006,-7.934000015258789 -3.6419999599456787,-6.52400016784668 C-4.795000076293945,-4.888000011444092 -6.050000190734863,-3.1059999465942383 -6.380000114440918,-2.638000011444092 C-6.434000015258789,-2.562000036239624 -6.519000053405762,-2.5199999809265137 -6.611000061035156,-2.5199999809265137 C-6.611000061035156,-2.5199999809265137 -7.938000202178955,-2.5199999809265137 -7.938000202178955,-2.5199999809265137 C-7.982999801635742,-2.5199999809265137 -8.020000457763672,-2.4839999675750732 -8.020000457763672,-2.437999963760376 C-8.020000457763672,-2.437999963760376 -8.020000457763672,9.447999954223633 -8.020000457763672,9.447999954223633 C-8.020000457763672,9.494000434875488 -7.982999801635742,9.531000137329102 -7.936999797821045,9.531000137329102z"></path> </g> <g opacity="1" transform="matrix(1,0,0,1,2.694000005722046,14.967000007629395)"> <path fill="rgb(255,255,255)" fill-opacity="1" d=" M0.5019999742507935,7.0269999504089355 C0.5019999742507935,7.0269999504089355 -0.5019999742507935,7.0269999504089355 -0.5019999742507935,7.0269999504089355 C-0.7789999842643738,7.0269999504089355 -1.003999948501587,6.802000045776367 -1.003999948501587,6.525000095367432 C-1.003999948501587,6.525000095367432 -1.003999948501587,-6.525000095367432 -1.003999948501587,-6.525000095367432 C-1.003999948501587,-6.802000045776367 -0.7789999842643738,-7.0269999504089355 -0.5019999742507935,-7.0269999504089355 C-0.5019999742507935,-7.0269999504089355 0.5019999742507935,-7.0269999504089355 0.5019999742507935,-7.0269999504089355 C0.7789999842643738,-7.0269999504089355 1.003999948501587,-6.802000045776367 1.003999948501587,-6.525000095367432 C1.003999948501587,-6.525000095367432 1.003999948501587,6.525000095367432 1.003999948501587,6.525000095367432 C1.003999948501587,6.802000045776367 0.7789999842643738,7.0269999504089355 0.5019999742507935,7.0269999504089355z"></path> </g> </g> </g> </g> </svg> <span>赞 <span id="like_label" class="like_label"></span></span> </button><div class="mt20 text-center article__reward-info"> <span class="mr10">如果觉得我的文章对你有用,请随意赞赏</span> </div> </div><!--support-author--> <!--/文章的页脚部件:打赏和其他信息的输出--> </div> </article> </div> <!--上一篇&下一篇--> <nav class="m-t-lg m-b-lg"> <ul class="pager"> <li class="next"> <a class="box-shadow-wrap-normal" href="https://tech.mindseed.cn/MediaWiKi/950.html" title="MediaWiki的SEO扩展——WikiSEO" data-toggle="tooltip"> 下一篇 </a></li> <li class="previous"> <a class="box-shadow-wrap-normal" href="https://tech.mindseed.cn/Win/952.html" title="Win11的一个bug——音量按钮可能出卖了你的浏览内容" data-toggle="tooltip"> 上一篇 </a></li> </ul> </nav> <!--评论--> <style> textarea#comment{ background-image: url('https://s2.ax1x.com/2019/07/20/ZzaGcV.png'); background-color: #ffffff; transition: all 0.25s ease-in-out 0s; } textarea#comment:focus { background-position-y: 105px; transition: all 0.25s ease-in-out 0s; } </style> <div id="comments"> <!--评论列表--> <div id="post-comment-list" class="skt-loading"><script type="text/javascript" id='outputCommentJS'> (function () { window.TypechoComment = { dom : function (id) { return document.getElementById(id); }, create : function (tag, attr) { var el = document.createElement(tag); for (var key in attr) { el.setAttribute(key, attr[key]); } return el; }, reply : function (cid, coid) { var comment = this.dom(cid), parent = comment.parentNode, response = this.dom('respond-post-949'), input = this.dom('comment-parent'), form = 'form' == response.tagName ? response : response.getElementsByTagName('form')[0], textarea = response.getElementsByTagName('textarea')[0]; if (null == input) { input = this.create('input', { 'type' : 'hidden', 'name' : 'parent', 'id' : 'comment-parent' }); form.appendChild(input); } input.setAttribute('value', coid); if (null == this.dom('comment-form-place-holder')) { var holder = this.create('div', { 'id' : 'comment-form-place-holder' }); response.parentNode.insertBefore(holder, response); } comment.appendChild(response); this.dom('cancel-comment-reply-link').style.display = ''; if (null != textarea && 'text' == textarea.name) { textarea.focus(); } return false; }, cancelReply : function () { var response = this.dom('respond-post-949'), holder = this.dom('comment-form-place-holder'), input = this.dom('comment-parent'); if (null != input) { input.parentNode.removeChild(input); } if (null == holder) { return true; } this.dom('cancel-comment-reply-link').style.display = 'none'; holder.parentNode.insertBefore(response, holder); return false; } }; })(); </script> <script type="text/javascript"> var registCommentEvent = function() { var event = document.addEventListener ? { add: 'addEventListener', focus: 'focus', load: 'DOMContentLoaded' } : { add: 'attachEvent', focus: 'onfocus', load: 'onload' }; var r = document.getElementById('respond-post-949'); if (null != r) { var forms = r.getElementsByTagName('form'); if (forms.length > 0) { var f = forms[0], textarea = f.getElementsByTagName('textarea')[0], added = false; var submitButton = f.querySelector('button[type="submit"]'); if (null != textarea && 'text' == textarea.name) { var referSet = function () { if (!added) { // console.log('commentjs'); const child = f.querySelector('input[name="_"]'); const child2 = f.querySelector('input[name="checkReferer"]'); if (child!=null){ f.removeChild(child); } if (child2!=null){ f.removeChild(child2); } var input = document.createElement('input'); input.type = 'hidden'; input.name = '_'; input.value = (function () { var _lg4pf = 'TND'//'TND' +//'P1v' '0'+'ef'//'k' +//'yvo' '9'+'2'//'DE' +'c3'//'m5f' +/* 'R'//'R' */''+/* '0kp'//'0kp' */''+'15a'//'Qg' +//'76T' 'bc'+'0'//'FI' +//'C' 'd'+//'KI8' '2'+//'GO' 'd2'+'1'//'uHm' +//'u' 'u'+'c38'//'PCk' +//'b' '8'+//'9T' 'b'+//'F' 'a3'+//'LK' 'b'+''///*'vS'*/'vS' +//'kk4' 'da'+/* 'B48'//'B48' */''+'a6'//'XZ' +'5'//'j' +/* 'V'//'V' */''+''///*'OH'*/'OH' +'c'//'lcu' , _21sW6hy = [[0,3],[18,19]]; for (var i = 0; i < _21sW6hy.length; i ++) { _lg4pf = _lg4pf.substring(0, _21sW6hy[i][0]) + _lg4pf.substring(_21sW6hy[i][1]); } return _lg4pf; })(); f.appendChild(input); input = document.createElement('input'); input.type = 'hidden'; input.name = 'checkReferer'; input.value = 'false'; f.appendChild(input); added = true; } };//end of reset referSet(); } } } }; $(function(){ registCommentEvent(); }); </script></div> <!--如果允许评论,会出现评论框和个人信息的填写--> <div id="respond-post-949" class="respond comment-respond no-borders"> <h4 id="reply-title" class="comment-reply-title m-t-lg m-b-none">发表评论 <small class="cancel-comment-reply"> <a id="cancel-comment-reply-link" href="https://tech.mindseed.cn/MediaWiKi/949.html#respond-post-949" rel="nofollow" style="display:none" onclick="return TypechoComment.cancelReply();">取消回复</a> </small> <div class="text-muted m-t-xs" style="font-size: 13px;line-height: 18px;"> <i style="vertical-align: -2px;width:14px;height: 14px" data-feather="alert-circle"></i> 使用cookie技术保留您的个人信息以便您下次快速评论,继续评论表示您已同意该条款 </div> </h4> <form id="comment_form" method="post" action="https://tech.mindseed.cn/MediaWiKi/949.html/comment" class="comment-form" role="form"> <input type="hidden" name="receiveMail" id="receiveMail" value="yes" /> <div class="comment-form-comment form-group"> <label class="padder-v-sm" for="comment">评论 <span class="required text-danger">*</span></label> <textarea id="comment" class="textarea form-control OwO-textarea" name="text" rows="5" placeholder="说点什么吧……" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('submit').click();return false};"></textarea> <div class="OwO padder-v-sm"></div> <div class="secret_comment" id="secret_comment" data-toggle="tooltip" data-original-title="开启该功能,您的评论仅作者和评论双方可见"> <label class="secret_comment_label control-label">私密评论</label> <div class="secret_comment_check"> <label class="i-switch i-switch-sm bg-info m-b-ss m-r"> <input type="checkbox" id="secret_comment_checkbox"> <i></i> </label> </div> </div> </div> <!--判断是否登录--> <div id="author_info" class="row row-sm"> <div class="comment-form-author form-group col-sm-6 col-md-4"> <label for="author">名称 <span class="required text-danger">*</span></label> <div> <img class="author-avatar" src="https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=65&r=G&d=" nogallery/> <input id="author" class="form-control" name="author" type="text" value="" maxlength="245" placeholder="姓名或昵称"> <div class="random_user_name shake-constant">🎲</div> </div> </div> <div class="comment-form-email form-group col-sm-6 col-md-4"> <label for="email">邮箱 <span class="required text-danger">*</span> </label> <input type="text" name="mail" id="mail" class="form-control" placeholder="邮箱 (必填,将保密)" value="" /> </div> <div class="comment-form-url form-group col-sm-12 col-md-4"> <label for="url">地址 </label> <input id="url" class="form-control" name="url" type="url" value="" maxlength="200" placeholder="网站或博客"></div> </div> <!--提交按钮--> <div class="form-group"> <button type="submit" name="submit" id="submit" class="submit btn-rounded box-shadow-wrap-lg btn-gd-primary padder-lg"> <span>发表评论</span> <span class="text-active">提交中...</span> </button> <i class="animate-spin fontello fontello-spinner hide" id="spin"></i> <input type="hidden" name="comment_post_ID" id="comment_post_ID"> <input type="hidden" name="comment_parent" id="comment_parent"> </div> </form> </div> </div> </div> <div class="resize-pane"> <div id="trigger_right_content" class="trigger_content"><div class="trigger_drag_content"></div></div> <div id="trigger_right_button" data-placement="left" data-toggle="tooltip" data-original-title="点击展开右侧边栏" class="normal-widget resize-pane-trigger box-shadow-wrap-lg"><i data-feather="sidebar"></i></div> </div> </div> <!--文章右侧边栏开始--> <aside id="rightAside" class="asideBar col w-md bg-white-only bg-auto no-border-xs" role="complementary"> <div id="sidebar"> <section id="right_first_section" class="widget widget_tabs clear"> <div class="nav-tabs-alt no-js-hide new-nav-tab-wrap"> <ul class="nav nav-tabs nav-justified box-shadow-wrap-normal tablist new-nav-tab" role="tablist"> <li data-index="0" class="active" role="presentation"> <a data-target="#widget-tabs-4-hots" role="tab" aria-controls="widget-tabs-4-hots" aria-expanded="true" data-toggle="tab"><div class="sidebar-icon" data-toggle="tooltip" title="热门文章" data-container="body"><i data-feather="thumbs-up"></i><span class="sr-only">热门文章</span></div> </a></li> <li role="presentation" data-index="1"> <a data-target="#widget-tabs-4-comments" role="tab" aria-controls="widget-tabs-4-comments" aria-expanded="false" data-toggle="tab"><div data-toggle="tooltip" title="最新评论" data-container="body" class="sidebar-icon"><i data-feather="message-square"></i><span class="sr-only">最新评论</span></div> </a></li> <li data-index="2" role="presentation"> <a data-target="#widget-tabs-4-random" role="tab" aria-controls="widget-tabs-4-random" aria-expanded="false" data-toggle="tab"> <div data-toggle="tooltip" title="随机文章" data-container="body" class="sidebar-icon"><i data-feather="gift"></i><span class="sr-only">随机文章</span></div> </a></li> <span class="navs-slider-bar"></span> </ul> </div> <div class="tab-content new-nav-tab-content"> <!--热门文章--> <div id="widget-tabs-4-hots" class="tab-pane fade in wrapper-md active" role="tabpanel"> <!-- <h5 class="widget-title m-t-none text-md">--><!--</h5>--> <ul class="list-group no-bg no-borders pull-in m-b-none"> <li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/680.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/MediaWiKi/680.html" title="MediaWiki的命名空间列表"> MediaWiki的命名空间列表 </a></h4> <small class="text-muted post-head-icon text-second"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">48345</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/Linux/802.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/Linux/802.html" title="如何清除npm中的缓存"> 如何清除npm中的缓存 </a></h4> <small class="text-muted post-head-icon text-second"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">9024</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/566.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/MediaWiKi/566.html" title="MediaWiki外观设置"> MediaWiki外观设置 </a></h4> <small class="text-muted post-head-icon text-second"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">7585</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E5%AE%9E%E7%94%A8%E6%89%A9%E5%B1%95%E7%A8%8B%E5%BA%8F%E4%BB%8B%E7%BB%8D.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E5%AE%9E%E7%94%A8%E6%89%A9%E5%B1%95%E7%A8%8B%E5%BA%8F%E4%BB%8B%E7%BB%8D.html" title="MediaWiki实用扩展程序介绍"> MediaWiki实用扩展程序介绍 </a></h4> <small class="text-muted post-head-icon text-second"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">5363</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/skills/444.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/skills/444.html" title="利用在线词频统计工具分析高频词"> 利用在线词频统计工具分析高频词 </a></h4> <small class="text-muted post-head-icon text-second"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">4896</span> </span> </small></div></li> </ul> </div> <!--最新评论--> <div id="widget-tabs-4-comments" class="tab-pane fade wrapper-md no-js-show" role="tabpanel"> <!-- <h5 class="widget-title m-t-none text-md">--><!--</h5>--> <ul class="list-group no-borders pull-in auto m-b-none no-bg"> <li class="list-group-item"> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E7%AE%80%E4%BB%8B%E5%8F%8A%E5%AE%89%E8%A3%85.html#comment-108" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E7%AE%80%E4%BB%8B%E5%8F%8A%E5%AE%89%E8%A3%85.html#comment-108" class="text-muted"> <!--<i class="iconfont icon-comments-o text-muted pull-right m-t-sm text-sm" title="" aria-hidden="true" data-toggle="tooltip" data-placement="auto left"></i> <span class="sr-only"></span>--> </a> <div class="clear"> <div class="text-ellipsis"> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E7%AE%80%E4%BB%8B%E5%8F%8A%E5%AE%89%E8%A3%85.html#comment-108" title="123"> 123 </a> </div> <small class="text-muted"> <span> 打赏的二维码出不来啊,作者(๑•̀ㅁ•́ฅ) </span> </small> </div> </li> <li class="list-group-item"> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E7%AE%80%E4%BB%8B%E5%8F%8A%E5%AE%89%E8%A3%85.html#comment-107" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E7%AE%80%E4%BB%8B%E5%8F%8A%E5%AE%89%E8%A3%85.html#comment-107" class="text-muted"> <!--<i class="iconfont icon-comments-o text-muted pull-right m-t-sm text-sm" title="" aria-hidden="true" data-toggle="tooltip" data-placement="auto left"></i> <span class="sr-only"></span>--> </a> <div class="clear"> <div class="text-ellipsis"> <a href="https://tech.mindseed.cn/Tutorial/MediaWiki%E7%AE%80%E4%BB%8B%E5%8F%8A%E5%AE%89%E8%A3%85.html#comment-107" title="123"> 123 </a> </div> <small class="text-muted"> <span> 第一 </span> </small> </div> </li> <li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/793.html#comment-105" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/MediaWiKi/793.html#comment-105" class="text-muted"> <!--<i class="iconfont icon-comments-o text-muted pull-right m-t-sm text-sm" title="" aria-hidden="true" data-toggle="tooltip" data-placement="auto left"></i> <span class="sr-only"></span>--> </a> <div class="clear"> <div class="text-ellipsis"> <a href="https://tech.mindseed.cn/MediaWiKi/793.html#comment-105" title="明玥"> 明玥 </a> </div> <small class="text-muted"> <span> 看起来 mediawiki的数学扩展是个大坑.还不如obsi... </span> </small> </div> </li> <li class="list-group-item"> <a href="https://tech.mindseed.cn/Website/1238.html#comment-104" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/Website/1238.html#comment-104" class="text-muted"> <!--<i class="iconfont icon-comments-o text-muted pull-right m-t-sm text-sm" title="" aria-hidden="true" data-toggle="tooltip" data-placement="auto left"></i> <span class="sr-only"></span>--> </a> <div class="clear"> <div class="text-ellipsis"> <a href="https://tech.mindseed.cn/Website/1238.html#comment-104" title="Eitan"> Eitan </a> </div> <small class="text-muted"> <span> 可以试试 Cloudflare 来解析域名,可以自动添加SSL... </span> </small> </div> </li> <li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/1104.html#comment-101" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/MediaWiKi/1104.html#comment-101" class="text-muted"> <!--<i class="iconfont icon-comments-o text-muted pull-right m-t-sm text-sm" title="" aria-hidden="true" data-toggle="tooltip" data-placement="auto left"></i> <span class="sr-only"></span>--> </a> <div class="clear"> <div class="text-ellipsis"> <a href="https://tech.mindseed.cn/MediaWiKi/1104.html#comment-101" title="公子猫"> 公子猫 </a> </div> <small class="text-muted"> <span> 监视列表就是一个收藏功能 </span> </small> </div> </li> </ul> </div> <!--随机文章--> <div id="widget-tabs-4-random" class="tab-pane fade wrapper-md no-js-show" role="tabpanel"> <!-- <h5 class="widget-title m-t-none text-md">--><!--</h5>--> <ul class="list-group no-bg no-borders pull-in m-b-none"> <li class="list-group-item"> <a href="https://tech.mindseed.cn/Maker/common-settings-for-raspberry-pi.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/Maker/common-settings-for-raspberry-pi.html" title="树莓派的常用设置"> 树莓派的常用设置 </a></h4> <small class="text-muted post-head-icon"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">673</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/WordPress/655.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/WordPress/655.html" title="WordPress后台运行奇慢无比"> WordPress后台运行奇慢无比 </a></h4> <small class="text-muted post-head-icon"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">558</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/BookStack/1032.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/BookStack/1032.html" title="再次升级BookStack遭遇git错误"> 再次升级BookStack遭遇git错误 </a></h4> <small class="text-muted post-head-icon"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">167</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/LimeSurvey/LimeSurvey%E6%B7%BB%E5%8A%A0-%E5%8A%A0%E8%BD%BD%E8%87%AA%E5%AE%9A%E4%B9%89js%E6%96%87%E4%BB%B6.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/LimeSurvey/LimeSurvey%E6%B7%BB%E5%8A%A0-%E5%8A%A0%E8%BD%BD%E8%87%AA%E5%AE%9A%E4%B9%89js%E6%96%87%E4%BB%B6.html" title="LimeSurvey添加/加载自定义js文件"> LimeSurvey添加/加载自定义js文件 </a></h4> <small class="text-muted post-head-icon"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">1436</span> </span> </small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/skills/use-the-method-of-remove-event-listeners-copy-content-from-web.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second text-ellipsis"> <a href="https://tech.mindseed.cn/skills/use-the-method-of-remove-event-listeners-copy-content-from-web.html" title="网页内容不让复制怎么办?"> 网页内容不让复制怎么办? </a></h4> <small class="text-muted post-head-icon"><span class="meta-date"> <i class="fontello fontello-eye" aria-hidden="true"></i> <span class="sr-only">浏览次数:</span> <span class="meta-value">959</span> </span> </small></div></li> </ul> </div> </div> </section> <!--博客信息--> <section id="blog_info" class="widget widget_categories wrapper-md padder-v-none clear"> <h5 class="widget-title m-t-none">博客信息</h5> <ul class="list-group box-shadow-wrap-normal"> <li class="list-group-item text-second"><span class="blog-info-icons"> <i data-feather="award"></i></span> <span class="badge pull-right">308</span>文章数目</li> <li class="list-group-item text-second"> <span class="blog-info-icons"> <i data-feather="message-circle"></i></span> <span class="badge pull-right">107</span>评论数目</li> <li class="list-group-item text-second"><span class="blog-info-icons"> <i data-feather="calendar"></i></span> <span class="badge pull-right">6年213天</span>运行天数</li> <li class="list-group-item text-second"><span class="blog-info-icons"> <i data-feather="activity"></i></span> <span class="badge pull-right">18 小时前</span>最后活动</li> </ul> </section> <!--非文章页面--> <!--文章页面--> <section id="tag_cloud-post" class="widget widget_tag_cloud wrapper-md clear"> <h5 class="widget-title m-t-none">文章标签</h5> <div class="tags l-h-2x panel wrapper-sm padder-v-ssm"> <a href="https://tech.mindseed.cn/tag/MediaWiki/">MediaWiki</a> <a href="https://tech.mindseed.cn/tag/SEO/">SEO</a> <a href="https://tech.mindseed.cn/tag/%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E%E4%BC%98%E5%8C%96/">搜索引擎优化</a> </div> </section> <div id="tag_toc_body" class="tag_toc_body"> <section id="tag_toc" class="widget widget_categories wrapper-md clear"> <h5 class="widget-title m-t-none">文章目录</h5> <div class="tags l-h-2x box-shadow-wrap-normal"> <div id="toc" class="small-scroll-bar overflow-y-auto"></div> </div> </section> </div> </div> </aside> <!--文章右侧边栏结束--> </div> </main> <div id="morphing-content" class="hidden read_mode_article"> <div class="page"> <h1 class="title">简单介绍几点MediaWiki网站的SEO优化方法</h1> <div class="metadata singleline"><a href="#" rel="author" class="byline">忆兰居士</a> • <span class="delimiter"></span><time class="date">2022 年 10 月 04 日</time></div> <textarea id="morphing-content-real_origin_text"><p>搜索引擎优化(SEO)的目的就是尝试让网站页面在搜索引擎结果中尽可能高。当然这也是有争议的:对它的支持者来说,这是获取网络流量必不可少的方式,而对它的批评者来说,往好了说,这是俗气的,往坏了说,这是小贩、垃圾邮件发送者和骗子的领域。尽管如此,对于那些运营公共维基的人来说,在搜索结果中排名靠前是很重要的。<br>首先,MediaWiki在搜索结果方面已经做得很好了。维基百科是基于MediaWiki的,它是搜索结果中表现最好的网站,无论以什么标准衡量:它通常是前三名,而且经常是关于它所涵盖的任何主题的搜索的第一名。这主要是因为它经常从其他网站链接到这些特定主题,但也有部分原因是MediaWiki自己的设计。<br>结合网上的信息和自己在建站过程中的有限经验,梳理了以下几条。</p><h2>一、重写网站的URL的形式</h2><p>其实就是MediaWiki的短链,如果刚安装完没有进行任何配置,通常我们打开的站点链接应该是这样的:</p><pre><code>yourwiki.com/index.php?title=首页 </code></pre><p>或者是</p><pre><code>yourwiki.com/index.php/首页 </code></pre><p>总之,看上去非常别扭。<br>所以,我们要做的就是改成<code>yourwiki.com/wiki/首页</code>、<code>yourwiki.com/w/首页</code>或者是<code>yourwiki.com/首页</code>(前两种是官方推荐的,最后一种是我目前在使用的,暂时也没有发现任何大问题)。<br>具体操作的话,可以参考本站的文章《<a href="https://tech.mindseed.cn/MediaWiKi/MediaWiki-ShortUrl.html">Mediawiki短链(Short URL)设置</a>》,这里就不再赘述了。</p><p>二、为站点创建sitemap</p><blockquote>Sitemap 可方便网站管理员通知搜索引擎,他们网站上有哪些可供抓取的网页。</blockquote><p>原理之类的就不多介绍了,其目的就是让爬虫爬取网站内容节省时间,让爬虫对网站的结构有整体的认识。<br>如何生成的话,可以通过某些在线站点进行,也可以通过MediaWiki的维护脚本或插件进行,具体参见本站文章《<a href="https://tech.mindseed.cn/MediaWiKi/938.html">为MediaWiki站点创建网站地图(sitemap)</a>》</p><p>三、自定义MediaWiki的robots.txt文件<br>默认情况下,MediaWiki有一些实用工具页面(如特殊页面等),这些页面不会对搜索引擎隐藏。使用robots.txt文件可以隐藏这些内容,避免被搜索引擎收录。比如:</p><pre><code>User-agent: * Disallow: /index.php?title=Special:* Disallow: /index.php?title=特殊:* Disallow: /index.php?title=%E7%89%B9%E6%AE%8A:* Disallow: /skins/ </code></pre><p>当然,如果你已经进行了短链设置,那么记得添加短链的形式</p><pre><code>Disallow: /Special:* Disallow: /特殊:* Disallow: /%E7%89%B9%E6%AE%8A:* </code></pre><p>具体方法参见官方网站中的<span class="external-link"><a class="no-external-link" href="https://www.mediawiki.org/wiki/Manual:Robots.txt/zh" target="_blank"><i data-feather="external-link"></i>手册</a></span>,至于你想要让搜索引擎搜到啥由你自己决定。中文<code>特殊:</code>其实并不会被正确解读,还是需要转成字符形式,放在其中一来是为了自己看起来方便,而来也是为了保险,谁知道是不是所有的爬虫都不支持中文呢。</p><h2>四、安装SEO扩展</h2><p>这里只推荐一款扩展——WikiSEO,它添加了wiki页面HTML源代码的<meta>和<title>标记。它定义了一个名为“#seo”的解析器函数,可以将它添加到页面的任何地方,并按以下方式调用它:</p><pre><code>{{#seo: title=... | titlemode=... | keywords=... | description=... }} </code></pre><p>详细介绍和具体用法可参见本站文章《<a href="https://tech.mindseed.cn/MediaWiKi/950.html">MediaWiki的SEO扩展——WikiSEO</a>》。</p><h2>五、条目分类的层级关系</h2><p>这是为了增加页面之间的相关性,既方便读者浏览也能更好地进行站点的内部链接。要说对搜索引擎到底有多大用的话,我也不清楚。</p><h2>六、提交信息给各大搜索引擎</h2><p>最后就是去百度、谷歌、必应、搜狗等站点管理工具中提交你的站点信息。网上的教程一抓一大把,这里就不写了。</p><h2>总结</h2><p>说到底,其实还是内容最重要,否则再怎么优化,搜索引擎也不傻。</p></textarea> <div id="morphing-content-real_origin"></div> </div> </div> <!-- footer --> </div><!-- /content --> <!--right panel--> <style> .topButton>.btn{ top: 0; } </style> <div class="topButton panel panel-default"> <button id="goToTop" class=" btn btn-default rightSettingBtn pos-abt hide border-radius-half-left" data-toggle="tooltip" data-placement="left" data-original-title="返回顶部"> <span class="settings-icon2"><i width="13px" height="13px" data-feather="corner-right-up"></i></span> <!-- <i class="fontello fontello-chevron-circle-up" aria-hidden="true"></i>--> </button> </div> <div class="tag_toc_body hide"> <div class="tocify-mobile-panel panel panel-default setting_body_panel right_panel" aria-hidden="true"> <button class="rightSettingBtn border-radius-half-left btn btn-default pos-abt " data-toggle="tooltip" data-placement="left" data-original-title="目录" data-toggle-class=".tocify-mobile-panel=active, .settings=false"> <span class="settings-icon2"><i width="13px" height="13px" data-feather="list"></i></span> </button> <div class="panel-heading">文章目录</div> <div class="setting_body toc-mobile-body"> <div class="panel-body"> <div id="tocTree" class="tocTree"></div> </div> </div> </div> </div> <footer id="footer" class="app-footer" role="footer"> <div class="padder-sm bg-white footer_wrapper box-shadow-wrap-normal b-normal"> <div class="pull-right hidden-xs text-ellipsis"> <a href="https://beian.miit.gov.cn/" target="_blank">沪ICP备15011154号-1</a> <a href="https://typecho.org/" style="margin-left: 5px" target="_blank"> <svg style="width: 16px;height: 16px;vertical-align: -4px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="30px" height="26px" viewBox="0 0 30 26" version="1.1"> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage"> <path d="M13,26 C3.36833333,26 0,22.631 0,13 C0,3.36866667 3.36833333,0 13,0 C22.6316667,0 26,3.36866667 26,13 C26,22.631 22.6316667,26 13,26 Z M6,9 L20,9 L20,7 L6,7 L6,9 Z M6,14 L16,14 L16,12 L6,12 L6,14 Z M6,19 L18,19 L18,17 L6,17 L6,19 Z" id="icon" fill="#000000" sketch:type="MSShapeGroup"/> </g> </svg> </a> <a class="highlightlink" href="https://www.ihewro.com/archives/489/" target="_blank"> <span>Theme by handsome</span> </a> </div> <span class="text-ellipsis">© 2024 All rights reserved. <a href="https://www.mindseed.cn" target="_blank">MindSeed</a> </span> </div> </footer> </div><!--end of .app app-header-fixed--> <!--定义全局变量--> <style> #mode_set{ display: none; } </style> <!--主题核心js--> <script src="https://tech.mindseed.cn/usr/themes/handsome/assets/js/function.min.js?v=9.2.120230801501"></script> <script src="https://tech.mindseed.cn/usr/themes/handsome/assets/js/core.min.js?v=9.2.120230801501"></script> <script> $(function () { if ('serviceWorker' in navigator) { if (LocalConst.USE_CACHE) { navigator.serviceWorker.addEventListener('controllerchange', function (ev) { try { if (LocalConst.SERVICE_WORKER_INSTALLED){ $.message({ title:"检测到本地缓存需要更新", message:"<a href='#' onclick='window.location.reload();'>点击刷新页面</a>更新本地缓存", type:'warning', time: '300000' }); }else{ console.log("controllerchange:first sw install success"); } }catch (e) { console.log("controllerchange error",e); } }); } } }) </script> <!--主题组件js加载--> <script src="https://tech.mindseed.cn/usr/themes/handsome/assets/js/features/jquery.pjax.min.js" type="text/javascript"></script> <!--pjax动画组件--> <!--主题组件js加载结束--> <!--用户自定义js--> <script type="text/javascript"> try{ }catch (e){ handsome_util.settingError("外观设置————开发者设置——自定义js"); console.error(e); } </script> </body> </html><!--html end--> <!-- / footer -->