WordPress is popular in the world Blog Station building Software It is very mature both in terms of interface and function. However, it is a little pity that WordPress mainly builds dynamic website pages, which consumes a lot of performance. Building a larger website with WordPress takes up more resources on the server side. In many cases, what we need is a completely static website.
A completely static website only has HTML files, which consumes very low server resources. Many places provide free hosting services for static websites. Therefore, the running cost of static websites is very low. In addition, static websites have low cost security In terms of the static access, the website can be accessed without any problems, such as static access, and there is no need to worry about the security of the website.
So, how to make a WordPress website completely static? Now I will talk about the method.
In WordPress's "Settings" - "fixed connection", set the fixed link to "custom structure", and add. HTML to the end of the title of the article. In this way, the article page will be displayed like a static page, but the contents and labels are still dynamic pages.
After that, turn off the comment function of WordPress, and in settings - discussion, select "automatically turn off the comment function on articles one day after publishing".
If the number of articles in WordPress is less than 1000, you can install a plug-in named simply static, which can generate a static website in a short time and provide download. This is very simple, needless to say.
However, if the number of articles is more than 5000, such as tens of thousands of articles, when using the simply static plug-in to generate HTML, an error will usually be reported, because the general web server will set a timeout and memory limit on PHP. Our usual solution is to build a PHP environment locally and modify the PHP timeout time and memory size, for example, for windows system For example, you can choose to install a software named "pagoda panel" to quickly configure a Wamp environment. After installation, you can modify the PHP timeout time and memory size in the environment. At this time, you can use the simply static plug-in to avoid errors.
Even so, for WordPress with tens of thousands of articles, the speed of simply static plug-in generating website is too slow, which is almost several hours. Here, we recommend using another static plug-in: wp2static plug-in.
In the wp2static plug-in, modifying the number of crawl increments to more than 100 can effectively improve the speed of page generation. However, when I use the wp2static plug-in, I also found some problems, which were successfully generated after several debugging.
1. The first page page page directory is missing. Only a few pages are generated on the first page, but other pages are not generated. My solution is to install a plug-in named WP pagenavi, and set the number of "displayed number of pages" as the maximum number of pages in the plug-in, so that all the first page pages can be generated.
2. The directory page is missing, and only one page is generated. My solution is to select "subdirectory on current server" in the "deploy static website". In this way, the website can be generated to a local directory. After that, in the crawling option, detect is added All three options in level run aside so that all the table of contents and article pages can be generated.
After these processing, we get a completely static HTML file of the website in the final directory, and then we publish these HTML files to the target website to get a completely static website. This static website does not need other PHP code of WordPress, and can support large traffic access. There are basically no security risks and vulnerabilities except for the trouble of updating Besides, other aspects are almost the same as the original WordPress, which is a good way to deploy the website with low cost and high quality.