Is it better to use multiple html pages and link them together with href
or just change content on the same page using JavaScript? I am thinking of how to layout a page and I don’t have a lot of content. It would probably be about three of for pages if I just used all html. If I toggled and swapped bits of html around using JavaScript, I could probably fit it all on one page, and it would be a bit “cooler”, in that it’s more of an application, dynamic, etc. But I’m just wondering what the best way to go here? Is it horrible to have to much JavaScript “squashed” to one document? How do you know where to draw the line when thinking about this?
7
The downsides you need to consider if you go with the “all on one page, swapped using Javascript” approach:
- Will people be able to bookmark or link to specific pages of information?
- Will people be able to use their browser’s back/forward buttons to navigate between pages on your site?
- Will people with Javascript disabled (small but non-zero population) be able to use your site at all?
- Will Google and other search engines be able to spider and index your content?
None of these problems are insurmountable, but they’re all problems you won’t have if you follow the traditional decades-old model of putting separate pieces of content on separate pages.
2
A good maintainable approach or practice
to follow would be using master page layout. While having separate content pages that are linked through your master page.
Here is a reference how to set it up, if you use pure HTML and CSS – Using a Master Page to create a 2 column CSS layout.
If you are using Visual Studio then you may also find it useful to look at the followings:
- Creating a Site-Wide Layout Using Master Pages (C#)
- Tutorial 3: Master Pages and Site Navigation