View Shtml
To execute SSI commands, the file must be processed by a web server.
Let’s create a simple project to demonstrate how to build and view an SHTML file.
Project Structure:
/your-website
index.shtml
/includes
header.html
footer.html
Step 1: Create header.html
<header>
<h1>Welcome to My Site</h1>
<nav><a href="/">Home</a> | <a href="/about.shtml">About</a></nav>
<hr>
</header>
Step 2: Create footer.html
<footer>
<hr>
<p>Page last modified: <!--#flastmod file="index.shtml" --></p>
<p>© 2025 My Company</p>
</footer>
Step 3: Create index.shtml
<!DOCTYPE html>
<html>
<head>
<title>My SHTML Page</title>
</head>
<body>
<!--#include virtual="/includes/header.html" -->
<main>
<p>This is the unique content of this page.</p>
<!--#echo var="DATE_LOCAL" -->
</main>
<!--#include virtual="/includes/footer.html" -->
</body>
</html>
Step 4: View the result.
When you navigate to index.shtml via your web server, you will see a fully assembled HTML page. The #include tags will be replaced with the actual content of the header and footer files.
To test SHTML locally, you must run a local server.
http://localhost/yourfile.shtml.| Method | Shows processed HTML? | Shows SSI directives? | Requires server? | Ease of use | |----------------------------|----------------------|------------------------|------------------|--------------| | Text editor | ❌ No (raw code) | ✅ Yes | ❌ No | Very easy | | Browser (file://) | ❌ No (raw code) | ✅ Yes | ❌ No | Very easy | | Browser (via http://) with SSI enabled | ✅ Yes | ❌ No | ✅ Yes | Moderate | | View Source in browser (HTTP) | N/A (source after parsing) | ❌ No | ✅ Yes | Easy | view shtml
If you request an SHTML file and see the actual code (e.g., <!--#include virtual="..." -->), SSI is not enabled. Here are the most common fixes.
| Problem | Likely Cause | Solution |
| :--- | :--- | :--- |
| Raw code displayed | Web server isn't parsing SHTML. | Add AddHandler server-parsed .shtml to .htaccess. |
| File not found (404) | Incorrect virtual path. | Use absolute paths relative to DOCUMENT_ROOT. Example: <!--#include virtual="/global/header.html" --> |
| Includes are blank | File exists but has wrong permissions. | Ensure included files (e.g., header.html) are readable by the web server (chmod 644). |
| Browser downloads file | MIME type is wrong. | Tell server to treat .shtml as text/html. |
| Local double-click fails | No server environment. | You cannot "view" SHTML without http:// in the address bar. Use localhost. |
<!--#echo var="DATE_LOCAL" -->
<!--#echo var="REMOTE_ADDR" -->
<!--#echo var="HTTP_USER_AGENT" -->
This will print the current date, the visitor's IP address, or their browser type, respectively.
When users search for “view shtml,” they typically mean one of two things: To execute SSI commands, the file must be
| Goal | Meaning | |----------------------------------------|--------------------------------------------------------------| | See the rendered page (as intended) | Execute SSI directives – needs a web server (Apache, Nginx) | | Inspect the source code | Open in any text editor or IDE – safe and straightforward |
Failing to distinguish between these two leads to confusion: opening an SHTML file directly in a browser shows a mix of HTML and unparsed directives like <!--#include virtual="menu.shtml" -->.
By default, many modern servers do not process .shtml files. You have to tell the server to look for SSI.
For Apache Servers:
You need to ensure the mod_include module is enabled, and add the following to your .htaccess file or server configuration: Step 1: Create header
AddType text/html .shtml
AddHandler server-parsed .shtml
Options +Includes
For Nginx Servers: You must enable the SSI module in your server block:
location /
ssi on;
Note: Modern web development often uses PHP (include 'file.php';) to achieve the exact same result as SHTML. However, SSI is lighter and faster because it doesn't require the PHP engine to load just to stitch a few HTML files together.