How do I reuse HTML code for different pages just like every popular website in existence? - html

On almost every website, they have various pages, each having the same HTML code. I strongly doubt that the creators of the websites edit the HTML code of each page, especially when users can make their own pages (like redditors making their own subreddits). These two pages from wikipedia: https://en.wikipedia.org/wiki/Synthesizer https://en.wikipedia.org/wiki/Drum_machine are different pages but they have very similar html code
And I don't even need to have users create their own pages, I just need to have multiple pages that reuse html code. https://www.apple.com/mac/ https://www.apple.com/ipad/ are clearly different pages that have different html code, but I don't think the developers would copy and paste HTML code, change it, then change the code of the headers in each page to include the new page when they have a new product.
https://getbootstrap.com/docs/4.3/getting-started/introduction/ and https://getbootstrap.com/docs/4.3/examples/ are different pages that use the same html code. What do they use? Should I learn bootstrap? I've seen websites do this way before bootstrap was made, though. What's something like this called? Do they even write in HTML or do they write in something that compiles into HTML? How am I supposed to do this very simple task that every webdev knows how to do yet I am unable to find any information on it?
I've tried searching for "Reusing HTML code" but I found nothing that answers my question. All I've seen are special cases
I'm hoping with this, I'll be able to have a website that can have multiple pages that use the same basic HTML code. If I wanted a new tab, I won't have to edit the HTML code of each page.

What you described is achieved by HTML templates and server-side scripting. The server script injects data in your HTML template, thus reusing one template for any number of pages. A template may consist of multiple parts that can be combined to achieve similarly looking yet different pages. It is called dynamic HTML.
Here is a very basic tutorial on how it works: https://www.php.net/manual/en/tutorial.php
To create a modern website you need to use a dozen different technologies together. Here is an infographic to give get idea: https://codeburst.io/the-2018-web-developer-roadmap-826b1b806e8d

They are many ways to do it!
If you are using asp.net you can use master page.
For more info : Master page demo
or else you can use php "include" statement. Suppose you created one page as header.php(header.html) and other one as footer.php(footer.html), then you just have to include those pages.
eg
<?php include 'header.php';?>
<html>your web page</html>
<?php include 'header.php';?>

Well this question is so extremely general it's hard to answer without knowing what your goal is. I highly doubt there are any web developers that develop a website from scratch anymore. Most use a content management system (CMS) which uses server side scripting to serve HTML pieces to form a website. For example header, footer, content-body I don't mean the HTML tags header and footer, although they will be part of the pieces the CMS serves. The most popular content management system is Wordpress, which is built in php. The pages don't even need to be specifically designated, they can be a list of blog posts, a picture gallery ...etc . There are many different CMS packages that serve different purposes and depend on your requirements. Wordpress is in my opinion the simplest with the lowest learning curve and is quite powerful, especially with all of the templates and plugins available. Wordpress itself is free and there are many free templates to start from. However, there are paid templates and plugins that offer additional features. The only thing that you need is php support and a hosting site.
All you need to know can be found here - https://codex.wordpress.org/Getting_Started_with_WordPress
Other content management systems include Joomla, Drupal, Magento, PrestaShop, TYPO3. Each have their advantages and disadvantages, as well as varying support for plugins and templates. Some are designed to support eCommerce sites, such as PrestaShop and TYPO3 but most CMS libraries provide support for eCommerce through plugins and templates.
Bootstrap is a framework, which is a little different from a CMS, but it offers a similar functionality. It serves different pieces or containers you design to form a website or page.
I recommend starting with Wordpress and if you have more specialized needs, check out the other options. I don't recommend you start writing php code to serve pages unless you are a very experienced php coder and even in that case why would you want to if there are so many free open source tools that have already done this for you.

Related

Is there any way to use a template file for my all HTML pages?

I am trying to design a web site. I am searching for a template to use on all of my pages, such as a news page, home page, about page, projects page, etc. I know that Dreamweaver has this feature, but is there any way to make it in my local workspace?
How can I have a logo or title in one place without copy and pasting it to every file?
There's many ways to make and use templates (and themes), all depending on the technologies you're using, capable of doing or would like to use.
WYSIWYG website software like Dreamweaver provide features for making website templates and themes, but you'll likely be tied to using their proprietary system.
I think most professionals don't like to be locked to proprietary local software like that. Instead they use server-side CMS systems and/or client-side frameworks. Most beginner's probably get exposed to the concept of templates and themes via the WordPress CMS, or via the basic CMS's you find at GoDaddy or Wix.
If you prefer to learn and code manually, and make your own system, that's great! There's tons of possibilities. Ultimately you'd be looking at using templates and/or themes, in one of two ways: Templates loaded client-side via a Javascript framework ... or ... templates loaded server-side via a CMS like WordPress.
This is a little complex, but it will work on most, if not all, modern web servers. For testing, you'll have to look into something like IIS.
Create a header HTML page as header.html with your logo, title, navbar, et cetera. Then in any file you will have to write: <?php include "header.html" ?>
This won't work unless you download and install PHP and set up a localhost, something you can learn how to do here.
This might not qualify as a template, but will work for your purposes.

How do front end developers create web templates to either sell or show their talents?

I am new to web design/web development, I have been learning on/off over the past year or so and believe I do have a good basic grasp on HTML, CSS and using text editors etc.
What I struggle to find or understand:
How do you devs create templates of websites without using a CMS ?
Do you just create HTML and CSS files and then somehow show them on the web, or do you have to use certain software to create the templates?
Templates are just HTML, CSS and Javascript files.
If you have a CMS as the backend of the website, you can integrate a template to your CMS however this is usually a manual process. However it's very important to note that a template and a CMS are two totally different things.
If you have any issued using a template with a specific CMS then feel free to post specific examples.

Diffrence between Wordpress themes and HTML, CSS?

This might be a stupid question, but I really cant understand the diffrence between creating websites with Wordpress or seperately with HTML,CSS. I see incredible Designed Wordpress templates.
So I cant understand are these wordpress templates added to an already created website or when you use wordpress there is no need to write code with html..? I am little confused ..
When using PHP, One of the main problems, if not the most important one, is that pages (including HTML, CSS, JS) are rendered inline PHP programs, which makes the pages fragmented and probably separated into different PHP programs, and makes developing themes somehow harder. That's why templates are widely used in modern frameworks like Django, Ruby on Rails.
Nevertheless, programming in PHP is much easier with the help of MVC frameworks and/or CMS systems. In CMS systems like Wordpress, the HTML parts and CSS parts (and JS parts) inline PHP programs are collected and put in a number of files, and the collection of these files are called Themes. So you can modify the themes or replace them, without touching the PHP code. Files in the themes are literally HTML/CSS/JS, if I'm not getting it wrong, and you can use them as a whole, or modify them according to the rules of Wordpress.
And yes you can write pages without the help of CMS systems like Wordpress, but CMS systems simplify the management and modification of pages, help you to reuse codes in one page or in different pages, and other features of CMS systems may also apply. You should check the feature list to see if there's anything you need and consider to prefer Wordpress over HTML/CSS/JS.

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.

Easiest CMS to Theme?

I'm trying to create a theme for a CMS, but it's proving nearly impossible, as I have no understanding of PHP or ASP.NET. I can put a site together via CSS and HTML, but I want clients to be able to add and edit content themselves. I'm about ready to give up on designing one altogether and just use an existing theme.
I've had a go at trying to understand the inner workings of Wordpress, SilverStripe, Umbraco and Pixie, but the tutorials have left me confounded. Are there other CMSes I should be looking into for a more simplified theming process?
I'd really love to be able to just drop a chunk of code into the content area of a given HTML page, and make that region editable from a WYSIWYG front end that the client can log into. Is there such a thing?
Anything but DotNetNuke.
I'd recommend giving Wordpress another try.
I'm no web developer, just a an average Java/C# programmer who needed a web site and has some basic knowledge of HTML and CSS. What I did was find a theme that was similar to what I wanted, then started tweaking it incrementally. My theme is pretty basic, but before long I got a pretty good grasp of "The Loop" and printing out category and page links and such.
How about Movable Type?
You can (and should) edit the templates via the web interface, they are divided into separate modules, so you can concentrate on one area of the site, styling is of course handled via CSS.
It took me a few hours without any prior experience with this CMS to completely port a Wordpress theme to MT - I found the documentation very helpful and didn't even have to look elsewhere.
An awesome thing about MT - it generates static pages based on the templates you defined. Meaning, very low load on the server, you don't need to query the database on every request, etc. You could probably do the same/similar by activating the cache plugin (or is it built in now?) in Wordpress, but here it's the default modus operandi so it's more stable and integrated with the CMS.
Drupal with the zen theme (or a "lighter" version of it: Starkish theme) seems like a popular choice (and well deserved, too). It gives you a good starting point, it has great documentation and many modules available.
PS: I've added this as an additional answer so that it can be voted upon separately from my other suggestion - I just could not stop myself from bringing up the Drupal + zen combo :)
I worked with Joomla, it is really easy to have a theme for it without knowing any programming language. When you install it using a simple installer, there will be a folder named templates. There are three simple themes each in its own folder. Just copy one of them,change XML data for that theme ( just to name it and have some details, no programming ) and change the contents of CSS and HTMLs. every where you see something unrelated to HTML like , copy them!! Names are descriptive. so you can guess what do they do. give it a try!
I'd really love to be able to just drop a chunk of code into the content area of a given HTML page, and make that region editable from a WYSIWYG front end that the client can log into. Is there such a thing?
The only system I've come across with this kind of functionality is Perch.
Just create your website using HTML/CSS as usual and chuck in a few small php tags where you want editable content. These areas are then added to an admin area for your clients to edit.
The only drawback is it costs £35 per site - I don't know if there's a free/open-source CMS with this functionality...
It's difficult to say which CMS will be the best one for you (maybe your question should be made into a community wiki question).
I have a little experience with mojoPortal, and found it to be easily customizable. There's a lot of documentation about how to skin your CMS and there a lots of complete skins that you can use as a starting point.
There is also a demo site, where you can see how the CMS works for an end-user.
Take a look at Joomla. That was the first CMS that I really used, and I still think its templating engine is better than most of the others out there.
Its template system essentially lets you build a standard web page, and then use some simple tags to define where the content and modules would go. You can override the output of most external components and modules without too much trouble, and the vast library of third-party extensions should help you add a ton of functionality to your site without much coding on your part. Joomla also has a fairly easy-to-use administrative backend, so your clients should like it too.
This page for themeing Wordpress helped me a lot:
Theme Development
UPDATE
Xichael,
If you know HTML and CSS pretty well, but you just don't want to spend time learning the Wordpress framework, then I think this is a good option for you (again, I can relate to your situation). Use Wordpress with the new Toolbox starter theme. It's super minimal.
Toolbox: An HTML5 WordPress Starter Theme
Here's an example of what it looks like. Just "View page source" and go to town on the CSS!
I've thought about writing my own very simple CMS just for handling pages, i.e. you have some sort of template, and then a <div> in the middle to drop in text from a WYSIWYG editor. You could even use XML as the data store to eliminate having to set up a database to store the page content.
It would sort of be re-inventing the wheel though, because there is so much polished CMS software out there already, but it wouldn't be that hard because it wouldn't have 99% of the features most systems have. However, what happens when your client wants to add something in the future that's already standard in an existing CMS or plugin?
If you are looking for a simple CMS tool, CMSimple is as basic as it gets. A small PHP based CMS system that does not even require a database or XML.
"CMSimple is the ideal tool for a single user to maintain a website."
Original version here: CMSimple.ORG
Original plus 2 enhanced versions here: Download CMSimple
117KB content manangement system
no database required; the entire site is stored in a single HTML file
built in WYSIWYG
no modules or widgets, no blog, no comments, etc., just basic pages
uses PHP (but no database)
Get themes here: dotcomwebdesign.com