Swaroop C H

blog books about contact subscribe

HTML Export feature for WordPress

05 Jan 2005

Here's an idea I thought of today.

I've been using WordPress 1.5 beta to maintain a worklog and I came across a situation today where a 'HTML export' feature would have been useful. I basically wanted to send a detailed description of a problem to a colleague but didn't want to send the URL of the blog itself (for obvious reasons). HTML export would have been useful because of all the formatting and other similar reasons.

We can extrapolate this idea to a HTML export of the whole blog where you can have a neat offline website in the form of a diary (or maybe even chapters of a book if you can imagine that) and send to others or simply use it as a backup. This is useful in case where I can't have a Apache server or MySQL etc. but still want to use or send across the information.

Does this 'feature' sound useful ?

I imagine implementing the HTML export by simply specifying a stream to file as the output for PHP instead of the usual stdout. Some of the tricks that might need to be done include export/saving of CSS and images to the output directory so that the HTML export is complete.

In case, it does sound useful and if some gurus on the WordPress Hackers list are willing to guide me, I might write this feature. However, I haven't written anything big in PHP till now.

( I originally wanted to post this on the hackers-at-wordpress-dot-org list directly but it is down at the moment )

Update

As you might have read in the comments section, I can achieve the same effect by writing a simple view.php where I can write the HTML and make the WordPress calls such as the_post() , etc. Why didn't I think of that before? Duh. To reiterate, the best solutions are always the simplest ones.

Comments

Carthik says:

Hi! I got your mail, but lost it in a spam wave. Sorry about that. The hackers list is now active again, so you can try that if you like.

There is a plugin that creates pdfs of each post. There was also ljbook.com that will make a pdf book out of a wordpress blog. There are plugins that make for easier emailing of posts. Considering this, would you still like to have an html export? Creating an html page with your post in it is as simple as saving the page from the browser as a .html page.

If you want to hide certain output, and make an page with only the post in it, you can create a new template, call it view.php or whatever else, and use only those template tags that show the content, and the stuff that you'd like, while omitting the others in index.php This is what Matt was referring to earlier.

Swaroop C H says:

Hey Carthik,

Thanks a ton for making that clear. The view.php seems to be a simple and easy way of achieving the same.

Matt says:

Couldn't this be done with a template?

Swaroop C H says:

Hey Matt,

Thanks for replying, but I quite didn't get how a template can accomplish the same thing? I know the answer will be simple but it just eludes me right now.

Lorelle says:

Did this ever go anywhere? And could you share your view.php with us so we know what it is. There are a lot of times when exporting a WordPress blog into HTML pages (one web page per post) would be perfect. Any suggestions?

Feedback

There's no comment box, but please do email me or tweet me your thoughts and criticisms, and I will publish the relevant ones here.