I'm trying to include one html file into another. I'm coding on the MAMP stack. I assume SSI's are automatically permitted. I type
<!--#include virtual="header.html" -->
in the body of one html file, the other file is called header.html, and they are both in the same folder. I even tried calling the file header.shtml instead. None of this works. It's frustrating.
The code isn't included. I'm including a form and a navigation bar, but they don't appear.
I assume SSI's are automatically permitted
That's a very big assumption. SSIs will only work if you've got mod_include loaded. You also need to enable the filter for the relevant files, e.g.
AddOutputFilter INCLUDES .shtml
...and of course ensure that Includes are not overridden elsewhere in the config.
Did you read this?
Related
I am trying to practice some web development with a simple HTML file and some external styling. I have my HTML and CSS files saved in the same folder, and am attempting to link the CSS to my HTML file. When I go to view the page, none of the styling is applied. There is a file called "styles.css" loaded into the sources tab, but it just looks like my HTML file. The HTML included is from the file I want to link by the name of the file in the sources. You can see the link attempt (I've tried with and without specifying type, and I've tried putting a slash in front of the name of the file), and you can see the file included in sources:
I've looked at each element, I've looked at the computed styles, and nothing suggests that the file is properly loaded. I've looked through several questions and most of the solutions are things I've already tried. Thanks!
Make sure the index file is saved as a .html file.
If it's still not working try href="./styles.css"
try writing href="./style.css"
I'm trying to use server side includes for both my header and navigation, as they will be constant across every page, and I'd like the ability to make frequent changes in one place and have them populate across all pages. I have tried a "file" and "virtual" include, and have tired placing the include files in the same directory. The include files have no duplicate code (doctype indicator, html tag, etc). I've also tried both .html and .shtml file extensions. I use the file explorer in DW to select the files, so I'm assuming the path is correct.
The SSI's preview fine in Dreamweaver, but will not populate in the browser. Any suggestions would be greatly appreciated.
<!--#include virtual="/lpapp/includes/influencer_header.shtml" -->
<!--#include virtual="/lpapp/includes/influencer_sidebar.shtml" -->
Dreamweaver probably support SSI. If you run your html from a random folder on your local PC, SSI won't work. As soon as you upload the project to a Apache webserver or a virtual server like Wamp/Mamp. It is possible to get SSI working using the right SSI syntax and .htaccess.
I, for the life of me, cannot figure out how to get these to work.
I currently have a file that is named "included.html" that I would like to be posted on another page, "a.html". The "included.html" contains both HTML and CSS. So within "a.html", I pasted the following code:
<!--#include file="included.html" -->
That did not work.
I contacted my hosting service to make sure they supported SSI and they said they did, just in the .shtml format.
So, I changed the file name to "included.shtml" and changed my code within "a.html" to the following:
<!--#include file="included.shtml" -->
Still does not work. I've even messed around with changing #include file to #include virtual. Doesn't work.
Any and all help is appreciated. Thanks.
Your server host is supporting SSI in pages that have the .shtml extension. Therefore, your include must be in a file with a .shtml extension, and the pages being included don't necessarily need the same extensions.
We have a page that has been using a server side include for many years. Recently it stopped working. No changes have been made to the page
<!--#include virtual="..\..\includes\nav.include" -->
Near the bottom of a page called contact.html
The 'nav.include' page simply contains html for a navigation bar. No javascript. No server side scripting. Just html.
Is there some setting somewhere that needs to be set to make SSIs work in the way it is implemented here (including a file with an uncommon extension inside a html file)?
A solution that I discovered yesterday:
I duplicated and renamed all my pages to .php (retained the original html files just in case!)
I have replaced all the {<#include virtual="folder_name/file_name.ext" -->} with
<?php include "folder_name/file_name.ext" ; ?>
with the appropriate number of dots and slashes depending upon where the pages are in my folder hierarchy. ( The {} above is to mark out the code only)
Finally, I renamed the original index.html to some other name so that the index.php is picked up instead of the index.html
This seems to be working out - I am still testing out all the pages and links - a very tedious and time consuming exercise!
INCLUDES SYNTAX:
In a php file use
<?php include "..//folder_name/file_name.ext" ; ?>
In an html file use
<!--#include virtual="../folder_name/file_name.ext" -->
EXPERIMENT WITH NUMBER OF "..." AND NUMBER OF "///" IN THE ABOVE SYNTAX TO GET THE CORRECT COMBINATION!!!!
For me, all my includes are small html files in a folder ABC which is directly under the webroot.
For pages which are under sibling folders of ABC i.e. in other folders directly under webroot, "..//" is the number of dots and slashes that work.
For pages which are directly in the webroot (i.e. not in any folder inside webroot), folder_name/file_name.ext without any dots or slashes has worked.
I haven't had the time to check out the number of dots and dashes required for any other level in the hierarchy!
I hope this helps!
Are you using GoDaddy? They did the same to my site, and I found on their forums someone that said to use include file instead of include virtual.
Just switched over to Godaddy servers and my SSI stopped working. I made a .txt file with the following:
AddHandler server-parsed .html
I uploaded it to the public html folder, then renamed it .htaccess, and everything started working.
I had too many files to convert all the extensions to PHP, so I had to find another answer, if at all possible.
For me, for a little while, exchanging include virtual to include file seemed to help, but then it broke again after a few days. I guess GoDaddy was not finishing monkeying around with the SSI configuration. o_O
The solution, as of tonight, was to convert all relative paths to absolute specification in regards to the site root. For example, I had to convert:
<!--#include virtual="..\..\includes\nav.html" -->
To:
<!--#include virtual="\includes\nav.html" -->
Using this approach, I was able to include HTML files inside other HTML files.
I discovered this on one of my pages that mixed absolute and relative path specification.
HTH
I've been seeing this problem frequently on my GoDaddy hosted site. I have to go into the Server configuration page, disable SSI, save the settings, then re-enable SSI and check "Use SSI on .HTM and .HTML files) and it starts working again.
The problem is on GoDaddy's side. For some reason, it's forgetting that it needs to parse SSI in files, until you turn off and turn on that option. Their Tier-2 support only suggested using Virtual instead of File on the Include command... which is preposterous, since not only does that not change a thing, the SSI includes work just fine most of the time... until it doesn't.
I'm also updating old .html pages to .php and replacing some of the with php include statements on all pages when some of the pages displayed [an error occurred while processing this directive].
The pages displaying the error also referenced an old .ssi file that wasn't even in the directory it pointed to. I deleted the old includes code to the non-existent .ssi file in those pages, and that fixed the error.
This error occurs when you have in your code html documentation like this
<!--#My awesome documentatacion-->
to fix it remove the #, like this
<!-- My awesome documentatacion-->
I'm using Doxygen to create html output.
I'd like to customize the output so that the index.html file could be more noticeable, since at the moment it is buried half way down a huge list of files in the html output folder.
For example, if it were moved up one directory to be outside of the 'bits and pieces' html files then it would be much more accessible for others who will be looking for it. However, I can't just ass a line of script to copy it to that location, since all of the links it has would break.
If I could configure Doxygen to have the index file go to a different location, or if you can think of another solution to my problem, I'd be grateful for your response.
Thanks
I would leave the documentation in its place and instead use the meta refresh option of the HTML language. Place a file, for instance called, "Documentation.html" in any folder you want with the following content
<meta http-equiv="REFRESH" content="0;URL=RELATIVE/PATH/TO/index.html">
As I mention in comments to the OP the easiest solution is probably to create a symbolic link or shortcut to the index.html file generated by doxygen, rather than trying to get doxygen to change the layout of it's output files. This symlink/shortcut can then be placed in the root directory of your project (or elsewhere), pointing to ./html/index/html, and named anything you like to make it obvious to your users what it is.