Skip to main content

Using blogger.com as a website instead of a blog

Thanks to the new functionality I am able to use the free blogger.com blogs as a website. It’s all thinks to functionally they added after Google acquired them. For example I created a custom template for my sister’s graphic/fashion/photography design website. In this post I’ll go over the basics that allow this to work.

1. Google allows custom domain names. This means the whole website can have a professional look and feel because all links connected to the site will look like www.nameofsite.com/revrefvrv/dfvdfvd… etc.

2. The use of labels, conditional statements, and the database data that blogger allows to be accessed through the template system.

To make a standard website I started with the simplest of the pre-created templates modifying it to suit my needs. I removed a lot of the functionality like comments, backlinks, and whatever else.

For a basic website you first need some links to blocks of site content. I generally hard code them into the template. Now if you’ve used the new blogger template system on a lower level (eg. the code level and not the drag and drop stuff) you will notice a few quips. They process any hard coded html data depending on where you put it, so you have to be careful what/where you place directly code into the template. Otherwise you can add “html/JavaScript” widgets to add whatever code functionality you want. The only problem with this is that all of that code you add is stored in the database and not the template. That kind of irritates me because it’s a pain to backup.

So I will add something like this where I want the menu to be:

<div class='divmenu'>
<span class='spanmenuitem'>
<a href='http://www.site.com/search/label/Whats%20New'>What's New</a>
</span>
<span class='spanmenuitem'>
<a href='http://www.site.com/search/label/Fashion%20Design'>Fashion Design</a>
</span>
</div>

As you can see, those are just hard coded links. It uses the label search functionality to find all posts that have that specific label attached to it.

So now you have links to site content on every page. Now we want to have a special page display only when the user goes to www.site.com… aka. the index page.
You will have to find the post section of the template:

<b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'>
    <b:includable id='main' var='top'>
        <div id='divcontentsection'>
            <!-- display the index page, or something else -->
            <b:if cond='data:blog.url == data:blog.homepageUrl'>
                <div id='divindexpage'>
                    This is the index page!
                </div>
            <b:else/>
                <b:loop values='data:posts' var='post'>
                    <b:include data='post' name='post'/>
                </b:loop>
            </b:if>
            <b:include name='nextprev'/>
        </div>
    </b:includable>
</b:widget>

Key points to note is the conditional statement checking ‘data:blog.url == data:blog.homepageUrl’. Every time the website is accessed it checks to see if the current page is the index page if it is it will display some html code, otherwise it will process site site as it generally would (show posts).

Now we have to figure out how to use labels to process the site content like a website would. I will talk through what I wanted to accomplish. After that will be the block of code that accomplishes the task.

* When a user clicks on a hard coded link to “Graphic Design”, I wanted it to display a list of post titles only related to graphic design, no actual content. Each title could be clicked on to go to that specific post. That means you need to have “Enable Post Pages?” set to YES in Settings->Archiving. Every post made has a unique link associated with it. It allows us to to use conditional statements to figure out to display the post content or not depending on what page they are on.

* I wanted to create html breadcrumbs. This is a goofy term for links that show your level of deepness in the site. For example “Home > Graphic Design > Ninjas” show what path the user took to get where they are. Each one can be clicked on so they can jump back. This is easily possible with blogger as you will see in the code later.

* Another thing is that I still want regular blog functionality in the site. When the user clicks on the “Whats New” link they should be shown all posts (title, content, everything…). All this takes is a quick check of what label the post has before it is processed.

Here is the code of the post includable that’s linked to from the previous code shown:

<b:includable id='post' var='post'>
    <div class='post'>
        <!-- this post functionality only works if there is ONE label -->
        <!-- look for special cases like whats new, we want that to display like a regular blog -->
        <!-- if it is a special case, display the content as well as the title+link -->
        <b:loop values='data:post.labels' var='label'>
            <b:if cond='data:label.name == "Whats New"'>
                <div class='divpostbody'>
                    <p>
                        <b:if cond='data:post.dateHeader'>
                            <h2><data:post.dateHeader/></h2>
                        </b:if>
                        <h3><a expr:href='data:post.url'><data:post.title/></a> - <data:post.timestamp/></h3>
                        <p>
                            <data:post.body/>
                        </p>
                    </p>
                    <div style='clear: both;'/> <!-- clear for photos floats -->
                </div>
            <b:else/>
                <!-- if this is not a single item, display only the title and link of each item -->
                <b:if cond='data:post.url == data:blog.url'>
                    <!-- START display breadcrumb links -->
                    <h4>
                        <a expr:href='data:blog.homepageUrl'>Home</a> |
                        <b:loop values='data:post.labels' var='label'>
                            <a expr:href='data:label.url'><data:label.name/></a>
                        </b:loop> |
                        <a expr:href='data:blog.url'><data:post.title/></a>
                    </h4>
                    <!-- END display breadcrumb links -->
                    <h3><data:post.title/></h3>
                    <div class='divpostbody'>
                        <p><data:post.body/></p>
                        <div style='clear: both;'/> <!-- clear for photos floats -->
                    </div>
                <b:else/>
                    <h3><a expr:href='data:post.url'><data:post.title/></a></h3>
                </b:if>
            </b:if>
        </b:loop>
    </div>
</b:includable>

It took me about 2 days to research and code the necessary functionality. Blogger’s current documentation on their template system leaves something to be desired. Hopefully they will improve on that. Anyways, that’s about it for the template! Now you should have a fully functional informational website that still has blogging functionality.

The code is a pain to paste into here, so if you have some troubles getting it to work, let me know.

Popular posts from this blog

ChatGPT is a new, and faster, way to do programming!

Currently ChatGPT is in a free “initial research preview” . One of its well known use cases at this point is generating software code. I’ve also just used it to write most of this article… Well, actually a future article about cleaning up SRT subtitle files of their metadata faster than I have been by hand with Notepad++ and its replace functionality. Update: I recorded a screencast of writing the SRT subtitle cleaner application loading and processing portion. I relied heavily on ChatGPT for code. It was a fun process! https://youtu.be/TkEW39OloUA ChatGPT, developed by OpenAI, is a powerful language model that can assist developers in a variety of tasks, including natural language processing and text generation. One such task that ChatGPT can help with is creating an SRT cleaner program. SRT, or SubRip Subtitle, files are commonly used to add subtitles to video files. However, these files can become cluttered with unnecessary information, such as timing lines or blank spaces. To clean...

Theme error in 2010s Android App after AppCompat Migration

I plan on releasing a lot of my old work as GPL open source, but most of it has aged to the point that it no longer functions, or if it does work it’s running in compatibility mode. Basically it’s no longer best practices. Not a good way to start off any new public GPL projects, in my opinion. The current project I’m working on is an Android app that calculates star trails meant to help photographers get or avoid that in their night time photos. For now I’m going to skip some of the import process because I didn’t document it exactly. It’s been mostly trial and error as I poke around Android Studio post import. The Android Studio import process… Removing Admob Google Play code before the project would run at all. After removing dependencies, it kind of worked, but when running it in the emulator it shows a pop-up message saying that the app was developed for an old version of Android. Going through the process of updating code to match current best practices… I had the IDE convert the ...

Printing to file in Linux WINE

I noticed that this post has been sitting as a draft since 2011. At this point I have no idea if it’s useful or what I was even doing, but I might as well make it public in case someone can find it helpful! So I’ve been trying to get one of those PDF print drivers working in WINE without success. I then came upon a process that might work. When printing you need to select the checkbox “Print to file” that creates a .prn file. Just Linux things... I was using a program that only has printing facilities, but I want to export around 100 pages of text and images. Once you have the .prn (postscript) file, you can do any number of things to it. In my case I want the postscript file to be converted to HTML. I am also considering PDF format because that has more conversion options to eventually get me to HTML or plain text. sudo apt-get install cups-pdf Or it looks like that package might have changed to this… sudo apt-get install printer-driver-cups-pdf Where PDFs would be generated in /home/...