Import HTML without using PHP? - html

Is there a way to import a block of HTML into a file without the use of something like PHP or Javascript? For my personal website, any time I make a small change to the content of my navbar, I have to go to all of my other pages and make that same change.

Do an internet search for "Server Side Includes for HTML"
Here's a good start:
http://en.wikipedia.org/wiki/Server_Side_Includes
Example:
<!--#include virtual="header.html" -->

No feature like the one you described is in the HTML spec, but if you don't have access to server configurations and the like, you can write your code in a language like HAML and compile it, which would accomplish what you described without any server-side work.

Related

How to Add Social Sharing Buttons on a static site?

I'm looking to Add social sharing buttons on a static which is having more than 500 Static Pages.
I can add manually but it's very tedious task so looking for an easy way to add.
Is there any Way to get the Permalinks of a Static Site Dynamically I'm thinking to pass it to the Sharing Code so that I can append the URL in the code if there is any way to add a piece of code automatically to all the pages it would be of great help.
Best Regards,
Arpit
You manually have created 500 pages or using php to generate dynamically?
If it is generated dynamically, you can easily add social share plugin to every page.
HTML code for social share by social9.com
https://www.social9.com/get-free-social-share/
...Select "code your own" from the list for HTML Code.
Yes, there is a way.
Use regular expressions in an IDE to find the right places and place the code in the replacing string.
If that's not enough powerful, then write a script, using e.g. Bash in Linux, or Groovy, or I would personally write a simple Java program leveraging the JSoup library.
Lastly, and I would recommend that most, give up maintaining the files manually, and switch to static site generating software, like JBake.
JBake can take your HTML pages and take their content as an input and re-generate the website through templates.

Server Side Include trouble in HTML document on Brackets

I have been trying to incorporate my navigation bar into each page of my website using a server side include. My goal is to be able to just change one file and each page would have the amendment. I have recently asked a question about this and got a solid response: <!--#include virtual="menu.cgi" --> or <!--#include file="footer.html" -->
This sounds like it works great but in my coding editor, brackets. It treats this as a comment and therefore does not work.
Server Side Includes, as their name suggests, are a feature of a web server.
They shouldn't "work" in a text editor. That is just a tool to let you edit the code. (And the syntax is designed to be the same as HTML comment syntax so that tools handling plain HTML will treat them as comments).
Test your code using a web server.

How do you work with include pages in jsp or php or the likes without getting IDE / Editor warnings for CSS classes?

If the CSS files for your site are referenced in the parent page, obviously you can use those CSS rules and classes in the sub-page or "included" page (like a jsp include or a php include). That will run as expected in the browser. BUT, if you are using an IDE or smart text editor of some kind (I'm using Netbeans), you will get warnings about the CSS elements in the sub-page (a .jspf for example) unless that file has a redundant reference to the css files. Is there a work-around for this? I don't want to have to reference the CSS files in both my jsp and my jspf (jsp include).
One technique I've used is to abandon jspf files in favour of a templating system where if you want to include something from a template, the template is actually a full page of which part is marked to be included. I actually use a home-grown template system for this, but my understanding is that thymeleaf (http://www.thymeleaf.org/) offers the same feature.

How to apply same content to multiple html pages

I'm new to html and was wondering if there is a way to apply the same content to many html files at once.
For example, if I have many pages, but all those pages have an identical navigation side panel that contains links to all the other pages. Is there any way to change the contents of this side panel without changing it for each individual page?
i.e. is there a feature that allows me to make this navigation panel in a separate file, then tell all my pages to include this navigation file?
I know a css file can control the format of many html pages - is there an analogy to this that can control the content of many html pages?
You can use PHP to do that. Write the HTML code in PHP file, then add include statement in your HTML. This saves you from having to write same code again and again specially for navigation, etc.
PHP manual explains it.
Hope it helps.
You can write the common content in javascript file and include it in your html pages using script tag:
<script src="YOUR_FILE.js"></script>
You can use an online HTML to Javascript converter like this one to generate you javascript code.
Server-side includes or server-side programming languages (like PHP, for example), are often used to do that. All pages just include a shared common file, which contains the common content.
<?php
include(file with extension);
?>
You'd have to change your file extension that runs this code to DOT php

Embedding HTML files in other HTML pages

I am new to HTML. I have an html page named "main.html" and i want to include another html page called "menu.html" in it. My main.html page doesn't include frames and it is designed using div tags. My site is hosted on linux based server The site I have to redesign is Java questions.
You want to look at Server Side Includes (SSI). This tutorial by Apache should get you up and running if that site is running on Apache.
There are plenty of Server Side ways of doing this, but all except SSI require the use of a language other than HTML.
If you're using IIS, you can check out Microsoft's writeup on Server Side Includes.
Check out server side includes.
You should use server-side includes.
i.e. in jsp you can use: <c:import url="/include/navigation.jsp" />, in php <?php include("/sidebar.php");?> and so on.
This is the good way to do what you need: include a navigation menu, or other parts common to all pages, without rewriting it in each page.
You can also do the same in other ways (with some javascript i.e.) but I doubt that you want to build a site called Java Questions without any server side language.
I think that PHP is the easiest way to do this. Most of the time you can just change your main.html file to main.php then add this php code where you want the menu bar:
<?php include('menu.html'); ?>
And that's it! You have to make sure that php is installed on your sever. Also this will ONLY work on a server. So if you are testing on your computer and using something like dreamweaver (or even a browser), you won't see anything until it's online.
You can make an ajax call in javascript if you want to avoid using the server.
In JQuery you would do:
<div id="putStuffHere">
</div>
<script>
$('#putStuffHere').load('myStuff.html');
</script>