How to use shtml include

How to use shtml include
By applying it, some public areas of the website can be made into independent pages, and then this technology can be used to embed them into other pages that need the content of this area.

mechanism:
The SSI mechanism is a dynamic inclusion rather than a static generation. When a web server such as Apache receives a user's request and parses it to find an SSI inclusion instruction, it automatically takes out the included page and embeds it into the requested page and sends it to the user as a whole page. The user has no idea what the server has done, but only knows that he has received a complete page.

benefit:
From the working mechanism of SSI, we know that the inclusion action occurs every time a user requests a page, so if the content of the included page changes, it can be reflected in real time. Because of this, it is very easy to use it to realize dynamic embedding of static pages. We can use it to implement the public area of ​​the entire website, or publish a lot of repeated area content into an independent static page, and then include it with SSI instructions where needed, such as the header and footer of the entire site, the latest news of the entire site, the hottest rankings, etc. This technology is widely used by most portal websites, such as 163, sina, etc.

How to implement the hottest content:
First, configure the SSI environment (refer to other SSI configuration tutorials)
Then create an independent node to create an additional publishing or article page, bind a small template that calls the hottest content, specify a path and file name, and then publish it as a static html page /hot.html
Then write the following SSI instructions in the box reserved for the hottest content on the homepage of the website
<!--#include virtual="/hot.html" -->
Change the extension of the home page to index.shtml (the default document page in the directory in the server configuration should also add the shtml type)
In this way, you can see the effect by using /index.shtml. After adding a bunch of articles, you only need to update this hot.html, and you don’t need to update the homepage

This method can even make the column list block on the homepage into this format. By utilizing the additional publishing function of each node, you can publish a small page with the content list of this node at the same time as publishing the column homepage, and then embed it on the homepage with SSI instructions. In the future, you only need to update the column content and the column additional publishing page, and the homepage does not need to be refreshed at any time!

<<:  Summary of web design experience and skills

>>:  Deployment and Chinese translation of the docker visualization tool Portainer

Recommend

W3C Tutorial (7): W3C XSL Activities

A style sheet describes how a document should be ...

Solution to "Specialized key was too long" in MySQL

Table of contents Solution 1 Solution 2 When crea...

js realizes the magnifying glass function of shopping website

This article shares the specific code of js to re...

Let's talk about the two functions of try catch in Javascript

The program is executed sequentially from top to ...

How to set focus on HTML elements

Copy code The code is as follows: <body <fo...

Multi-service image packaging operation of Dockerfile under supervisor

Writing a Dockerfile Configure yum source cd /tmp...

How to connect to virtual machine MySQL using VScode in window environment

1. Virtual Machine Side 1. Find the mysql configu...

How to quickly build a static website on Alibaba Cloud

Preface: As a junior programmer, I dream of build...

How to use lazy loading in react to reduce the first screen loading time

Table of contents use Install How to use it in ro...

How to encapsulate axios in Vue project (unified management of http requests)

1. Requirements When using the Vue.js framework t...

Several solutions for CSS record text icon alignment

It is very common to see images and text displaye...

The role of MySQL 8's new feature window functions

New features in MySQL 8.0 include: Full out-of-th...