搜索引擎优化(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">0</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/default/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 _75Sg = //'nOd' '0e'+'f'//'N' +''///*'Jk'*/'Jk' +'9'//'Gc' +'2'//'hO' +''///*'e'*/'e' +//'cSP' 'c3'+'15'//'va' +//'xV' 'ab'+//'0YE' 'c'+//'Cw' '0'+//'X' 'd2d'+'Mig'//'Mig' +'WQK'//'WQK' +'21c'//'cT' +//'g' '3'+'bNY'//'bNY' +'88'//'A' +'b'//'Dal' +//'LWg' 'a3b'+//'BZt' 'daa'+'65'//'v' +'c'//'7Qt' , _RhDF4L = [[16,19],[16,19],[20,23]]; for (var i = 0; i < _RhDF4L.length; i ++) { _75Sg = _75Sg.substring(0, _RhDF4L[i][0]) + _75Sg.substring(_RhDF4L[i][1]); } return _75Sg; })(); 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">发表评论 <small data-toggle="tooltip" data-placement="right" title="使用cookie技术保留您的个人信息以便您下次快速评论,继续评论表示您已同意该条款"> <i style="vertical-align: -1px" data-feather="alert-circle"></i> </small> <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> </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="tabs-4" class="widget widget_tabs clear"> <div class="nav-tabs-alt no-js-hide"> <ul class="nav nav-tabs nav-justified box-shadow-bottom-normal tablist" 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 wrapper-sm"><i data-feather="thumbs-up"></i></div><span class="sr-only">热门文章</span> </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 class="sidebar-icon wrapper-sm"><i data-feather="message-square"></i></div> <span class="sr-only">最新评论</span> </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 class="sidebar-icon wrapper-sm"><i data-feather="gift"></i></div> <span class="sr-only">随机文章</span> </a></li> <span class="navs-slider-bar"></span> </ul> </div> <div class="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/604.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/MediaWiKi/604.html" title="如何用插件创建我的第一个MediaWiki信息框模板"> 如何用插件创建我的第一个MediaWiki信息框模板 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views"> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">6</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"> <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"><span class="meta-views"> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">5</span> </span></small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/default/780.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/default/780.html" title="提问的智慧"> 提问的智慧 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views"> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">4</span> </span></small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/How-to-import-Wikipedia-Templates-into-your-own-MediaWiki.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/MediaWiKi/How-to-import-Wikipedia-Templates-into-your-own-MediaWiki.html" title="如何将 Wikipedia 中的模板导入到自己的 MediaWiki 中"> 如何将 Wikipedia 中的模板导入到自己的 MediaWiki 中 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views"> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">3</span> </span></small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/771.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/MediaWiKi/771.html" title="如何在某个条目中调用其他条目的内容——采用Excerpt模板"> 如何在某个条目中调用其他条目的内容——采用Excerpt模板 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views"> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">3</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/cross.html#comment-61" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/cross.html#comment-61" 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/cross.html#comment-61" title="bw"> bw </a> </div> <small class="text-muted"> <span> mediawiki想更新非常困难,最安全的更新方法竟然是不去增... </span> </small> </div> </li> <li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/578.html#comment-60" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/MediaWiKi/578.html#comment-60" 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/578.html#comment-60" title="bw"> bw </a> </div> <small class="text-muted"> <span> Xms设置1g,实际占用5g。。。难怪之前占用90%+ </span> </small> </div> </li> <li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/578.html#comment-59" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/MediaWiKi/578.html#comment-59" 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/578.html#comment-59" title="bw"> bw </a> </div> <small class="text-muted"> <span> /var/lib/elasticsearch 目录删除,安装6... </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#comment-57" class="pull-left thumb-sm avatar m-r"> </a> <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#comment-57" 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%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#comment-57" title="百科"> 百科 </a> </div> <small class="text-muted"> <span> 你好,我的那个显示小星星的扩展,图片无法显示,打开图片直接就是... </span> </small> </div> </li> <li class="list-group-item"> <a href="https://tech.mindseed.cn/LimeSurvey.html#comment-56" class="pull-left thumb-sm avatar m-r"> </a> <a href="https://tech.mindseed.cn/LimeSurvey.html#comment-56" 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/LimeSurvey.html#comment-56" 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"> <li class="list-group-item"> <a href="https://tech.mindseed.cn/LimeSurvey/LimeSurvey%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/LimeSurvey/LimeSurvey%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E.html" title="LimeSurvey配置文件说明"> LimeSurvey配置文件说明 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views "> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">0</span> </span></small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/Website/662.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/Website/662.html" title="LNMP还是放弃宝塔面板使用了OneinStack "> LNMP还是放弃宝塔面板使用了OneinStack </a></h4> <small class="text-muted post-head-icon"><span class="meta-views "> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">0</span> </span></small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/MediaWiKi/mediawiki-template-loop-detected.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/MediaWiKi/mediawiki-template-loop-detected.html" title="检查到模板循环"> 检查到模板循环 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views "> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">0</span> </span></small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/Linux/720.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/Linux/720.html" title="使用PowerShell和Linux bash免密登录同一台服务器"> 使用PowerShell和Linux bash免密登录同一台服务器 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views "> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">0</span> </span></small></div></li><li class="list-group-item"> <a href="https://tech.mindseed.cn/LimeSurvey/LimeSurvey%E7%9A%84%E7%9F%AD%E9%93%BE-%E4%BC%AA%E9%9D%99%E6%80%81-%E8%AE%BE%E7%BD%AE.html" class="pull-left thumb-sm m-r"></a> <div class="clear"> <h4 class="h5 l-h text-second"> <a href="https://tech.mindseed.cn/LimeSurvey/LimeSurvey%E7%9A%84%E7%9F%AD%E9%93%BE-%E4%BC%AA%E9%9D%99%E6%80%81-%E8%AE%BE%E7%BD%AE.html" title="LimeSurvey的短链(伪静态)设置"> LimeSurvey的短链(伪静态)设置 </a></h4> <small class="text-muted post-head-icon"><span class="meta-views "> <span class="right-small-icons"><i data-feather="message-circle"></i></span> <span class="sr-only">评论数:</span> <span class="meta-value">0</span> </span></small></div></li> </ul> </div> </div> </section> <!--博客信息--> <section id="blog_info" class="widget widget_categories wrapper-md clear"> <h5 class="widget-title m-t-none text-md">博客信息</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">232</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">57</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">5年71天</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">3 天前</span>最后活动</li> </ul> </section> <!--非文章页面--> <!--文章页面--> <section id="tag_cloud-2" class="widget widget_tag_cloud wrapper-md clear"> <h5 class="widget-title m-t-none text-md">文章标签</h5> <div class="post-tags tags l-h-2x"> <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 text-md">文章目录</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="fix-padding 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="fix-padding 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 overflow-y-auto"></div> </div> </div> </div> </div> <footer id="footer" class="app-footer" role="footer"> <!-- <div class="wrapper bg-light">--> <!-- <a class="pull-right hidden-xs text-ellipsis">--> <!-- <span class="label badge" style="margin-right: 10px;">Powered by typecho</span>--> <!-- <a href="https://www.ihewro.com/archives/489/" class="label badge">Theme by handsome</a>--> <!-- </a>--> <!-- <a href="" target="_blank" rel="noopener noreferrer" class="label badge" data-toggle="tooltip" data-original-title="">Copyright ©2021</a>--> <!-- </div>--> <div class="wrapper bg-light"> <span class="pull-right hidden-xs text-ellipsis"> <a href="https://beian.miit.gov.cn/" target="_blank">沪ICP备15011154号-1</a> Powered by <a target="_blank" href="http://www.typecho.org">Typecho</a> | Theme by <a target="_blank" href="https://www.ihewro.com/archives/489/">handsome</a> </span> <span class="text-ellipsis">© 2022 Copyright <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=8.4.12022041901"></script> <script src="https://tech.mindseed.cn/usr/themes/handsome/assets/js/core.min.js?v=8.4.12022041901"></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"> </script> </body> </html><!--html end--> <!-- / footer -->