Fork me on GitHub

建站分享之网站优化(一)

使用 Dareboost 进行网站质量和性能分析

Dareboost 是国外一个对网站进行在线评测的平台,良心推荐。

使用方法 :非常简单,打开后输入你的域名即可对网站作分析。

下面我根据 Dareboost 报告进行了相应的优化。

1.robots.txt file should be defined

Indicate to web crawlers which URLs should be explored on your website.

The robots.txt file

Place your robots.txt file in the root of the website. It will be interpreted by the robots in charge of your SEO. It delivers instructions to specify the pages to explore by robots, like Google bot.

Note that these directives are indicative only. A lambda robot will not be blocked by the restrictions specified by the file.

We have not detected the robots.txt file on this website, you should define one:

http://jantc.cn/robots.txt

解释:应定义robots .txt文件,向web爬虫指示应该在您的网站上浏览URL。将您的robots .txt文件放在网站的根目录下。这将由负责你的搜索引擎优化的机器人解释。它提供了指示,指定页面,以探索机器人,如谷歌机器人。

解决方法:

在你的站点文件夹中,git bash运行下面这两行代码:

npm install hexo-generator-sitemap@1 –save
npm install hexo-generator-baidu-sitemap@0.1.1 –save

在站点配置文件中添加代码:

1
2
3
4
5
# hexo sitemap网站地图
sitemap:
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml

配置成功后,hexo编译时会在hexo站点根目录生成sitemap.xml和baidusitemap.xml。其中sitemap.xml适合提交给谷歌搜素引擎,baidusitemap.xml适合提交百度搜索引擎。

其次,在站点根目录下新建一个robots.txt文件,其中添加下面的一段代码(具体网站改为你自己的网址):

1
2
3
4
5
6
7
8
9
10
11
12
# hexo robots.txt
User-agent: *
Allow: /
Allow: /archives/
Disallow: /vendors/
Disallow: /js/
Disallow: /css/
Disallow: /fonts/
Disallow: /vendors/
Disallow: /fancybox/
Sitemap: http://jantc.cn/sitemap.xml
Sitemap: https://jantc.cn/sitemap.xml

2.Group 9 JavaScript files

Each HTTP request affects the performance of your webpage (e.g., roundtrip time and bandwidth usage).

For example, it is better to request a unique 50 kB file instead of requesting 10 files that are 5 kB in size.

How should I distribute scripts?

Distribute your scripts by integrating them directly into your HTML or grouping them in files. We recommend using the latter method to take advantage of caching mechanisms.

You should consider grouping the following resources:

http://jantc.cn/lib/jquery/index.js?v=2.1.3
http://jantc.cn/lib/velocity/velocity.ui.min.js?v=1.2.1
http://jantc.cn/lib/velocity/velocity.min.js?v=1.2.1
http://jantc.cn/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7
and 5 others

解释:每个http请求都会影响网页的性能(例如,往返时间和带宽使用)。例如,最好请求一个唯一的50 kb文件,而不是请求大小为5kb的10个文件。

3. 38 CSS selectors are duplicated

Using several times the same selector for several declarative blocks within a single CSS file can affect the readability and maintainability of the code. It is also an optimization opportunity: by grouping these elements within a single rule, you will reduce the file size.

解释: 在单个CSS文件中使用多个声明块的相同选择器可以影响代码的可读性和可维护性。这也是一个优化机会:通过将这些元素分组在一个规则中,您将减少文件大小。叫我合并相同的css样式

4.Explain the purpose of each form field

Clarify the purpose of each field will facilitate the user experience on your website.

A form is composed of several fields that must be the most explicit possible for the user to quickly understand their function.

解释: 明确每个字段的用途将有助于您的网站上的用户体验。表单由几个字段组成,这些字段必须是用户能够快速理解其函数最明确的。(pass)

………

Thanks!