Integrating Blogger into an External Application Environment

By default, Blogger generates the main blog page and supporting archives as HTML extensions, but this is easy to change if you want to include ASP or PHP, or any other type of server-side script. For instance, as mentioned earlier, we use a comment system called dotcomments that’s based on PHP. We’ve also added a PHP date and time function, showing our current date and time (handy when you have blog readers from around the world). To support this functionality, we need to save our files as PHP-based files.

To change the blog to generate files with a .php extension, access the Settings view and the Publishing tab. In the page, you’ll want to change the blog filename to index.php instead of index.htm or index.html, whichever you already have. Save this change. If the archives also need the extension changed, access the Archive view next. Again, change the archive filename to a .php extension. The same extension will be used for all archive files. (Though the Archive index file won’t usually need to have the extension change — it won’t have server-side script — the filename is used as the basis for all other archive files, which is why you’ll need to make the extension name change.)

Republish the archives and the main blog page. The files are now saved as PHP files rather than HTML. At this point, you can open the blog template and add your server-side script as you would a regular file.

Get Essential Blogging now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.