How to set up a dynamic website with javascript only (no servers)

Here is my problem: I want to create a website, mostly static, but with some dynamic parts (a small blog for news, etc.). My web server can only make static files (this is actually the Dropbox public directory!), But I don’t want to repeat the layout on every html page!

Now I see two possible solutions: either create an index.htm page that emulates site navigation using javascript and AJAX, or I create all different html pages and then somehow import the layout bits using javascript ..

From you I need ideas and suggestions on how to implement this, which libraries to use, or maybe there is even something specifically for what I need?

Thanks!!

+4
source share
5 answers

I would define the site layout in your index.html file and then use JavaScript and Ajax to load the actual content into the div content on the page. This way your content files (extracted by Ajax) will be more or less regular HTML, with CSS classes defined in index.html. In addition, I would not recommend creating a blog in pure HTML and JavaScript. That would not be very interactive; no comments, ratings, etc. You can save the contents of your blog in XML, and then get and display it using Ajax and JavaScript.

While on the topic of XML, you can implement all your site content in XML. You must also save the list of pages (to create navigation) in XML format.

+2
source

jQuery allows you to easily load a section of one page into another page . I recommend uploading general navigation sections to different pages, and not vice versa, to avoid feedback problems. The layout can be done using a separate CSS file, rather than using tables, to minimize the amount of duplicate code. For a blog, you can put each entry in a separate file and upload each section individually.

However, I would just use something already available. TiddlyWiki , for example, is a standalone wiki that's all in one file. It is very customizable, and a blog plugin is already available there. You can work on the site with a hard drive or a USB drive, and then you can upload it to the Internet when it is done. There is nothing more.

0
source

Another way. You can generate static HTML on your computer and upload the result to Dropbox. Take a look at emacs muse .

0
source

Have you considered using publishing software on your computer to combine your content with a template, resulting in a set of static pages that you can then upload to Dropbox?

In this regard, some options come:

To handle comments, you can use Disqus . It embeds a complete comment system on your site using only JavaScript.

0
source

You can use Google Closure templates . This is one of the fastest and most versatile solutions for javascript templates.

0
source

All Articles