Welcome to WebmasterWorld Guest from 3.214.184.124

Forum Moderators: open

How do you manage common HTML code ?

This is about HTML/CSS web sites (with no CMS)

     
9:49 am on Nov 3, 2019 (gmt 0)

New User

Top Contributors Of The Month

joined:Sept 13, 2019
posts: 12
votes: 0

Hi,
I hope this is a suitable forum for this question.

I am building a web site with lots (well more than 10! potentially 100) pages,
Certain bits, like the navigation, the header, the footer are more or less the same on almost every page.

When coding a web site in pure HTML / CSS (ie not using a Content Management System software package or web site) how do you manage the common parts of the layout, without having to maintain it lots of times over?

Thanks
Jonathan
11:21 am on Nov 3, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4601
votes: 376


As soon as I have worked out the appearance and layout I want then I save a page template. When I want a new page, I just open the page template and edit in the content for that page. The template uses placeholders in the head area for title, description meta. Planning is important so that you have a basic concept for navigation in mind from the beginning.
12:13 pm on Nov 3, 2019 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Feb 10, 2002
posts:939
votes: 5


I have always used 'includes' for the common elements such as index, footers, etc. Well, after they became the thing, since, I started making sites in the 90s before their inception......
I generally used PHP includes.
12:14 pm on Nov 3, 2019 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Feb 10, 2002
posts:939
votes: 5


Sorry, forgot to say....
Using includes allows updating across the site by editing one include file.
12:46 pm on Nov 3, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4601
votes: 376


Yes, includes allow you to have a basic sidebar that you edit one for the relevant areas of the site. Depending on the site structure, there may be one or more navigation menus and footers. The HTML5 semantic elements are quite handy to keep that part of your pages clearly visible to you or any assistants.

Some of us have noticed that the HTML5 semantic elements also make it easier for scrapers to snip out what they came for: [webmasterworld.com...] - It depends on how paranoid you are about your content.
5:44 pm on Nov 3, 2019 (gmt 0)

New User

Top Contributors Of The Month

joined:Sept 13, 2019
posts: 12
votes: 0


Thanks guys,

Templates are a problem if everytime the sidebar changes you have to upate 100 pages with the same edit - I think, unless there is some way of automating that.

Yes, "includes" of some kind would be what I am looking for.

I don't use PHP and am not aware of HTML5 includes - does such a thing exist?

Ah... I see there is a JavaScript solution: [w3schools.com...]
Maybe that's my best answer?

PHP includes do look a very neat solution, provided my web host provides PHP support - I will have to check that. I guess I would need to install PHP locally on a web server to test my site before upload to the web?

Jonathan
5:55 pm on Nov 3, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15956
votes: 898


I hope this is a suitable forum for this question.
Personally, I think it isn't. The question should be asked either in the HTML subforum, or in the subforum concerned with your specific server (Apache or IIS).

Now then! I think two different things are getting mixed up, leading to confusion.

#1 HOW you achieve the include. It can be done either within the programming language (such as php) that builds the page, OR it can be done as a Server Side Include (SSI in Apache). Mechanics will depend on your server type--Apache, IIS and so on--so questions should be posted in the appropriate subforum.

#2 WHAT is in the include. It can either be plain html that is added as-is to every page, or it can be in the programming language of your choice. Yes, you can include php content into a page with html extension and so on. A php-or-similar include can be dynamic, so you can for example make a page-specific navigation header while avoiding the annoyance of a page that links to itself (as would happen if you included the same raw html on all pages).
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members