Using iframes in the place of proper 'master pages' - html

I've been told I have to make a 100% HTML CSS Javascript site for a project at school. I'm used to the master pages of asp.net and I'm worried about how I'm going to do a huge website without the use of them.
After thinking about it for a while, I came up with what I think is an ok solution. Using iframes...
Would it be safe to make one page that has an iframe instead of a content area to connect to other pages to make it appear as if we used a master page?
It seems kind of hacked up so, is there a better way? Is there any software (hopefully free) that provides a decent system of master pages?
Thanks!

You could use a js-based template engine, such as jQuery templates.

You could just dreamweaver and use dreamweaver templates.

Template-Toolkit includes the ttree utility, which will do what you want. You can build the site from templates to get plain, static HTML documents. Since this takes place at build time, you do not need anything like ASP / PHP / Perl / etc on the server at runtime.

Related

How to embed another website into my own web to keep the same header

We have a web app that we want to integrate in the websites of several clients by a subdomain, since in most cases we cannot modify their webs. Besides, our web is build in a different language and we want to keep it in our servers.
At the moment, they are adding links on their site's menu to our subdomain, however, they want to keep the same header and the footer so that the user feels that they are on the same website.
For now, we are copying the html and inserting it in our template, but this is not a good solution for the future and we are having several problems due to javascript conflicts.
How can we solve this? An iframe does not allow us to modify its content, I think. Thanks in advance.
Don't know any good ways to do this client side.
First thought is to have all the pages link your Javascript to create the header/footer, but it's not good to require Javascript to display content.
HTML imports would really be perfect for this, but it not well supported. You can consider if you're willing to use a polyfill, like Google's webcomponents.
I feel like best approach here would be to do this somehow not on client side. Either use a server that lets you use a template engine, or some static site generator that supports templating.

Common ways to target links?

Are iframes still widely in use today?
I am coding a site with divs, and I want everything to appear in the container div. Is it possible to do it without coding the header + nav into each page and have the content show at the exact same spot without using iframes?
I did a quick Google search and found a post that said it's not possible, but my site will have quite a bit of links.
As of right now, I am coding it with Tumblr, and the hashtags in the posts would act as links to a section of posts (Ex: #blog would retrieve every post under the "blog" link). What are some widely used ways to target links on a website?
If you are creating a multi-page website, it would be helpful to have the HTML content be generated dynamically or be built statically from template files. You don't want to manually update the same content across multiple HTML files.
Dynamic Pages
There are several options for dynamically generating HTML content depending on the software available to you. For example, PHP is a popular language for web development and is available through many web hosts.
Static Pages
It is possible to build static HTML documents from templates using something like Jekyll.
I'm not sure if I'm interpreting what you mean by "coding it with Tumblr" correctly or not, but I think you mean you're making a Tumblr site with their built-in HTML editing capability.
I think you'll have a very difficult time achieving the behavior you desire there. I think you're trying to create something resembling a single-page application. Tumblr probably just allows basic static HTML with little Javascript. The suggestion Kyle made about using PHP or something like that won't work because that code must be executed on a server, and Tumblr doesn't provide that capability to my knowledge.
If you really want this kind of functionality, you probably should get some paid web hosting and develop your web development skills. It's not a simple task, but it's fun!
Sorry if I underestimated you or anything. Just trying to read between the lines. It seems to me that you may be relatively new to web development given the content of your post, and I'm trying to nudge you in the right direction constructively.

How to create a template in HTML?

I started creating web pages in plain HTML. I have a header, main content and a footer. The main content is divided into two, left and right content. Everything is the same on all pages except for the right content. Now I have about 15 pages. This is very tiresome if I make some changes on the other static pages (header, footer and left side content) as I have to go through all pages.
How can I create one HTML file for each static area and how am I going to integrate it?
There are, essentially, three places you can do this:
At build time. Run a script that puts the pages together and outputs static HTML. Then upload the static HTML to the server. Back in 2013 I recommended ttree, but these days static site builders are common and more powerful. My projects tend towards Gatsby (for complex projects) and Metalsmith (for simpler ones). Jekyll is very popular (and Github provides documentation for using it with GH Pages).
At runtime on the server. This could be a simple SSI, a PHP include or a full template system (of which there are many, including Template Toolkit and mustache), possibly running inside an MVC framework (such as Catalyst or Django). This is the most common approach, it has less time between making a change and putting the result life then doing the templating at build time.
At runtime on the client. This adds a dependency on client-side JavaScript (which can be fragile and unfriendly to search engines), so I wouldn't recommend it unless you already had a server-side or build-time solution in place. Gatsby, for example, is a static site generator that builds a React frontend backed by static pages.
There are a couple of ways to do this.
If you are working purely with HTML, then you can use a 'server side include' -- this is a tag which allows you to load a file into the page (see http://en.wikipedia.org/wiki/Server_Side_Includes). Whoever is hosting your website has to support this.
<!--#include virtual="../quote.txt" -->
If youe web host happen to use PHP, you can do this using the include method (see http://php.net/manual/en/function.include.php):
<?php include('path_to_file/file.htm');?>
This will include the file at the point you place the tag. But again, whoever is hosting your site needs to support this.
There are other methods of doing this, bit these are the two I make use of.
Well... what you’re looking for is called "Master Page" and unfortunately it isn’t available in html however you can use the <iframe> tag but it would make your website look really ugly. i would suggest you to use a programming language such as PHP its much easier that way.
but if you want to use <iframe> then They’ll load remote pages into your website, so you could define a "Master Page" like this:
<body>
<div id="content">
<iframe src="content1.html"></iframe>
Now, inside of content1.html, you could just write the content without the main layout

How to create DRY HTML?

I have a small static website and every page of this site has a menu and a footer.
What is the best way to make sure changes in the menu and the footer only need to be done in one place and enable me to easily update all my pages which consist of them.
I am looking for some kind of simple template system that enables me to combine files together.
I have looked a bit into ruby .erb files but they seem too complicated for what I want to achieve as I would have to install rails and enable my webserver to use that.
For a simple site, there's nothing wrong with doing server side includes. Simply create the HTML snippets (they don't even have to be fully formed HTML) for your menu and footer. Then on each page, add the appropriate
<!-- #include virtual="/footer.html" -->
statement in the proper location. Since you're on a Debian server, I'm pretty sure Apache wil already have this enabled by default.
It may seem antiquated, but my wife works for a company that does a lot of maintenance for small websites and they still take this approach and it works just fine.
If your site goes above 10 pages, then I'd say look into some of the templating systems, just to alleviate the need to remember to add your SSI on each new page you create.
you could have a look at some Web Templating Systems and decide based on the language/platform you are familiar with
I use Octopress. It's a static site generator built on top of Jekyll which uses markdown for content markup and specific template language for constructing pages. So if you only need a site with a few pages you should try jekyll.
It requires for your system to have ruby since all site generation is done on client side and afterwards the site is deployed via rsync.
Try searching the internet for static site generator. It gives dozen of solutions in all sort of languages: Python, Ruby, PHP, Haskell, Sh, Bash…
Do you need to combine those on the server side?
For a small static site I simply created a little local script (I used PowerShell, but feel free to use whatever you want or have at your disposal) that does deployment from the local source files which represent the templates. While maybe not as flexible on the template side as full-blown templating engines it's easy, fast and works well for quite a while. Also it runs locally and doesn't need anything except a simple web server on the server side, cutting down on potential vulnerabilities.
I've used WML ("Website Meta Language"; NB nothing to do with the WML associated with mobile and WAP!) on Debian for years to maintain consistent templated header/sidebar/footer boilerplate for pages on my ISP's static page hosting.

Best way to use the same HTML on static web-pages

If you use dynamic pages like JSP or asp.net, you can have your page template included, and then content added. But what if you have no server-side component and all pages are just HTML/JS? You can of course create a template then copy it for each page, but then if you want to change something you risk having to modify every page, even if you put most styling in CSS properly.
Are there any non-awful ways to do this? I could see that an iframe could be used to load the content into the central page but that sounds nasty. Does HTML provide any way to include a base file and add to it?
You can use Server Side Includes to include other files on the server. It's similar to scripting languages like ASP or php, but SSI is usually supported by the server directly, so it's available on many servers, even if there is scripting language available.
The answer is still templates. Just process them offline instead of on the server. I like to use ttree for this.
You can create the pages offline and render into HTML, and deploy those to the site.
One option might be: https://github.com/thewml but it does feel ... "too much". I also saw asciidoc for creating sites ( https://asciidoc.org/ ) and I also used several times doxygen for that ( http://www.doxygen.nl/ ).
I also saw CMS that create static HTML files, but hey are no longer maintained.