Table of Contents
1. Turn on HTTPS
2. Gzip compression
3. Statistics
4. Functional plug-ins
5. Comment function
6. Full-text search
7. SEO
8. PWA 兼容
9. 修改样式
10. 手写插件
Home Web Front-end Vue.js Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

Mar 24, 2022 pm 08:07 PM
vuepress Optimization tips blog

After building a VuePress blog, there is actually a lot of optimization work that needs to be done. This article will take stock of the 10 optimizations that must be done after completing the basic construction.

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

[Related recommendations: vuejs video tutorial]

1. Turn on HTTPS

Turning on HTTPS has many benefits , for example, it can realize data encryption transmission, etc., and SEO will also be easier to include:

Google will give priority to HTTPS web pages (rather than equivalent HTTP web pages) as canonical web pages

Enable HTTPS, our basic steps are:

  • Purchase and download the certificate

  • Upload to the server

  • Open Nginx configuration

For specific steps, please refer to "VuePress Blog Optimization: Turning on HTTPS"

https://github.com/ mqyqingfeng/Blog/issues/246

2. Gzip compression

Turning on Gzip compression will greatly improve the website loading speed, especially if the server uses pay-per-traffic. It is what must be done.

If you are using Nginx, since Nginx has a built-in Gzip compression module, it can be turned on directly:

server {
  # 这里是新增的 gzip 配置
  gzip on;
  gzip_min_length 1k;
  gzip_comp_level 6;
  gzip_types application/atom+xml application/geo+json application/javascript application/x-javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/xhtml+xml application/xml font/eot font/otf font/ttf image/svg+xml text/css text/javascript text/plain text/xml;
}
Copy after login

For more information about Gzip compression, please refer to "VuePress Blog Optimization: Turn on Gzip Compression"

https://github.com/mqyqingfeng/Blog/issues/248

3. Statistics

After adding statistics, you can see the website’s For access and source information, Baidu Statistics and Google Statistics are often added. In China, it is recommended to use Baidu Statistics.

It is very simple to add statistical code. It is often only used after the statistical platform generates the code and then adds it to the site. For example, Baidu’s statistical code is:

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?82a3f80007c4e88c786f3602d0b8a215";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
Copy after login

Just be aware that since VuePress is a single Page application, during the page switching process, the page will not be reloaded, and naturally Baidu statistics will not be triggered. So we can only count the pages visited by users, but we don’t know which articles were clicked or which routes were redirected. In order to implement data statistics during route switching, we also need to monitor route changes and report data manually.

For more specific steps, please refer to "VuePress Blog Optimization: Adding Data Statistics Function"

https://github.com/mqyqingfeng/Blog/issues/245

4. Functional plug-ins

If you want to add various functions to the site, you don’t necessarily have to write various codes by yourself, you can also directly use ready-made plug-ins.

For example, announcement plug-in:

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

Code copy plug-in:

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

Background music plug-in:

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

Banbanniang plug-in:

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

#For more plug-ins and effects, please refer to "Building a VuePress Blog, You May Some plug-ins used》

https://github.com/mqyqingfeng/Blog/issues/261

5. Comment function

If a website has The comment function can establish communication with readers, optimize the site, and update errors in articles in a timely manner.

Add comment function, the mainstream is to use Valine and Vssue.

Valine is a fast, simple and efficient backend-free comment system based on LeanCloud, which is a Serverless cloud service that provides one-stop backend services, such as data storage and instant messaging. etc. To use Valine, you need to register LeanCloud. Registering LeanCloud and using the service requires real-name authentication. The final effect is as follows:

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

For specific operation steps, please refer to "VuePress Blog Optimization" Adding Valine comment function》

https://github.com/mqyqingfeng/Blog/issues/268

And Vssue is a Vue-driven, Issue-based comment plug-in. Although there are multiple hosting platforms available, here I use GitHub, and I have achieved synchronization with my GitHub article issues. The final effect is as follows:

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

For specific operation steps, please refer to "VuePress Blog Optimization: Adding Vssue Comment Function"

https://github. com/mqyqingfeng/Blog/issues/270

VuePress’s built-in search will only build search indexes for the title, h2, h3, and tags of the page. If you need full-text search, you can use Algolia search.

Algolia 是一个数据库实时搜索服务,能够提供毫秒级的数据库搜索服务,并且其服务能以 API 的形式方便地布局到网页、客户端、APP 等多种场景。

像 VuePress 官方文档就是使用的 Algolia 搜索,使用 Algolia 搜索最大的好处就是方便,它会自动爬取网站的页面内容并构建索引,你只用申请一个 Algolia 服务,在网站上添加一些代码,就像添加统计代码一样,然后就可以实现一个全文搜索功能:

Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!

具体的步骤参考 《VuePress 博客优化之开启 Algolia 全文搜索》

https://github.com/mqyqingfeng/Blog/issues/267

7. SEO

如果希望自己的站点能被搜索引擎做到,就要做好 SEO,而 SEO 牵涉的地方有很多,新手建议先看下基础的文档进行学习:

  • 《百度搜索引擎优化指南2.0》

    https://ziyuan.baidu.com/college/courseinfo?id=193&page=3

  • Google 搜索中心《搜索引擎优化 (SEO) 新手指南 》

    https://developers.google.com/search/docs/beginner/seo-starter-guide?hl=zh-cn

很多事情是一定要做的,比如自定义标题、描述、关键词,优化链接、重定向、生成 sitemap,并提交到搜索引擎平台,再辅助使用多个站长平台,及时发现和优化问题。

具体可以参考:

  • VuePress 博客之 SEO 优化(一)sitemap 与搜索引擎收录

    https://github.com/mqyqingfeng/Blog/issues/272

  • VuePress 博客之 SEO 优化(二)之重定向

    https://github.com/mqyqingfeng/Blog/issues/273

8. PWA 兼容

PWA,英文全称:Progressive Web Apps, 中文翻译:渐进式 Web 应用。

实现 PWA,可以方便的让我们的网站实现桌面图标、离线缓存、推送通知等功能。

要实现 PWA 参考 《VuePress 博客优化之兼容 PWA》

https://github.com/mqyqingfeng/Blog/issues/263

9. 修改样式

网站样式总有一些不满足你期望的地方,有的时候,就需要自己修改代码。

如果你要修改主题色,VuePress 定义一些变量供以后使用,你可以创建一个 .vuepress/styles/palette.styl 文件:

// 颜色
$accentColor = #3eaf7c
$textColor = #2c3e50
$borderColor = #eaecef
$codeBgColor = #282c34
$arrowBgColor = #ccc
$badgeTipColor = #42b983
$badgeWarningColor = darken(#ffe564, 35%)
$badgeErrorColor = #DA5961

// 布局
$navbarHeight = 3.6rem
$sidebarWidth = 20rem
$contentWidth = 740px
$homePageWidth = 960px

// 响应式变化点
$MQNarrow = 959px
$MQMobile = 719px
$MQMobileNarrow = 419px
Copy after login

如果你要自定义样式,你可以创建一个 .vuepress/styles/index.styl 文件。这是一个 Stylus文件,但你也可以使用正常的 CSS 语法。

更多的颜色修改参考 VuePress 的 palette.styl

https://vuepress.vuejs.org/zh/config/#palette-styl

10. 手写插件

有的时候,现有的插件实在满足不了要求,你就需要自己写一个插件了,但是你还要注意,我们写的是一个 VuePress 插件还是一个 markdown-it 插件,比如我们复制代码,我们可以使用 VuePress 插件来实现,但是如果我们要给代码块加一个 try 按钮,点击跳转到对应的 playground 页面,那就是拓展 markdown 语法了,就需要写一个 markdown-it 插件了。

但无论你写哪种插件,都提供了文章:

  • VuePress  插件:《从零实现一个 VuePress 插件》

    https://github.com/mqyqingfeng/Blog/issues/250

  • Markdown-it 插件:《VuePress 博客优化之拓展 Markdown 语法》

    https://github.com/mqyqingfeng/Blog/issues/251

(学习视频分享:vuejs教程web前端

The above is the detailed content of Summary and sharing: 10 must-do optimizations after establishing a VuePress blog!. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Multithreading optimization techniques in C++ Multithreading optimization techniques in C++ Aug 22, 2023 pm 12:53 PM

With the development of computer technology and the improvement of hardware performance, multi-threading technology has become an essential skill for modern programming. C++ is a classic programming language that also provides many powerful multi-threading technologies. This article will introduce some multi-threading optimization techniques in C++ to help readers better apply multi-threading technology. 1. Use std::thread C++11 introduces std::thread, which directly integrates multi-threading technology into the standard library. Create a new thread using std::thread

Start from scratch and guide you step by step to install Flask and quickly establish a personal blog Start from scratch and guide you step by step to install Flask and quickly establish a personal blog Feb 19, 2024 pm 04:01 PM

Starting from scratch, I will teach you step by step how to install Flask and quickly build a personal blog. As a person who likes writing, it is very important to have a personal blog. As a lightweight Python Web framework, Flask can help us quickly build a simple and fully functional personal blog. In this article, I will start from scratch and teach you step by step how to install Flask and quickly build a personal blog. Step 1: Install Python and pip Before starting, we need to install Python and pi first

What are the top ten open source PHP blog systems in 2022? 【recommend】 What are the top ten open source PHP blog systems in 2022? 【recommend】 Jul 27, 2022 pm 05:38 PM

Blog, also translated as web log, blog or blog, is a website that is usually managed by individuals and posts new articles from time to time. So how to set up a blog? What are the PHP blog systems? Which blogging system is best to use? Below, PHP Chinese website will summarize and share the top ten open source PHP blog systems with you. Let’s take a look!

Create a simple blog: using PHP and SQLite Create a simple blog: using PHP and SQLite Jun 21, 2023 pm 01:23 PM

With the development of the Internet, blogs have become a platform for more and more people to share their lives, knowledge and ideas. If you also want to create a blog of your own, then this article will introduce how to use PHP and SQLite to create a simple blog. Determine the needs Before starting to create a blog, we need to determine the functions we want to achieve. For example: Create a blog post Edit a blog post Delete a blog post Display a list of blog posts Display blog post details User authentication and permission control Install PHP and SQLite We need to install PHP and S

What are the optimization techniques for C++ recursive functions? What are the optimization techniques for C++ recursive functions? Apr 17, 2024 pm 12:24 PM

To optimize the performance of recursive functions, you can use the following techniques: Use tail recursion: Place recursive calls at the end of the function to avoid recursive overhead. Memoization: Store calculated results to avoid repeated calculations. Divide and conquer method: decompose the problem and solve the sub-problems recursively to improve efficiency.

ECharts chart optimization: how to improve rendering performance ECharts chart optimization: how to improve rendering performance Dec 18, 2023 am 08:49 AM

ECharts chart optimization: How to improve rendering performance Introduction: ECharts is a powerful data visualization library that can help developers create a variety of beautiful charts. However, when the amount of data is huge, chart rendering performance can become a challenge. This article will help you improve the rendering performance of ECharts charts by providing specific code examples and introducing some optimization techniques. 1. Data processing optimization: Data filtering: If the amount of data in the chart is too large, you can filter the data to display only the necessary data. For example, you can

MySQL and PostgreSQL: Performance comparison and optimization tips MySQL and PostgreSQL: Performance comparison and optimization tips Jul 13, 2023 pm 03:33 PM

MySQL and PostgreSQL: Performance Comparison and Optimization Tips When developing web applications, the database is an indispensable component. When choosing a database management system, MySQL and PostgreSQL are two common choices. They are both open source relational database management systems (RDBMS), but there are some differences in performance and optimization. This article will compare the performance of MySQL and PostgreSQL and provide some optimization tips. Performance comparison comparing two database management

Sharing optimization tips for batch Insert statements in MyBatis Sharing optimization tips for batch Insert statements in MyBatis Feb 22, 2024 pm 04:51 PM

MyBatis is a popular Java persistence layer framework that implements the mapping of SQL and Java methods through XML or annotations, and provides many convenient functions for operating databases. In actual development, sometimes a large amount of data needs to be inserted into the database in batches. Therefore, how to optimize batch Insert statements in MyBatis has become an important issue. This article will share some optimization tips and provide specific code examples. 1.Use BatchExecu

See all articles