There are still a lot of blog themes out there with little or no comments in the design. If your simply uploading the theme and changing the logo then this isn’t something that you will not really have problems with. However, anything beyond that i would strongly advise adding comments throughout your design.
2 minutes adding comments to your templates and coding can save you 10-20 minutes trying to get to grips with your design again at a later date.
This applies to bloggers who are just making small edits to there and also to those who have created their theme from scratch. Try and get in the habit of adding a comment to any significant change to your templates.
When i talk about a significant change i mean something that will not take 2 seconds to find at a later date which is usually the case with the majority of plugins or modifcations you make.
In the past i have been stupidly arrogant and lazy about this kind of thing. If i’ve been working a lot on a site and know the files inside out i have got lazy and left out comments. It’s only when i come back to the design 6 months later and i have’t got a clue where everything works that i kick myself for not commentating the file better.
How do you add Comments
You add comments differently in different programming languages but since the majority of popular blogs are coded with PHP and designed using HTML and CSS, those are the ones i use here.
In HTML the basic code you use is this :
<!-- Add your Comment Here -->
The comment is not displayed publicly - its just a reminder to you about something. For example, some wordpress themes have dozens of css divisions in each template. It can get very confusing sometimes when your not sure which closing div tag belongs to which div
Therefore i always make sure i leave a comment explaining what division its closing like this :
<div id="sidebar">
sidebar code
</div> <!– End of Sidebar –>
In CSS you can start a comment using /* and end a comment using */.
For example :
/* Sidebar CSS Code */
#sidebar {
width:200px;
float:right;
}
In PHP all you need to do to comment is add // at the start of every line you want to comment.
For example the top of your index.php file could look like
<?php
//
// this is the index.php file
//
Summary
Unless you’ve got a photographic memory, i would strongly advise getting into the habit of adding comments whenever you are working on your files. It really can save you a lot of hassle in the long run.
Good luck,
Kevin























TechZilo | May 24th, 2007 at 8:42 am #
Didn’t know how to comment PHP code, and got it now. Thanks for the tip, Kev.
I have found commenting the only way to solve the problem in my blog.
In my Blogger blog, I would lose track of the hacks and coding I did, and often revert the whole template.
Now, there’s no such problem!
Techie Buzz | May 24th, 2007 at 11:09 am #
I religiously follow commenting code may it be a simple html or a programming code.
It really helps others understand what you are trying to do.
EngineerTiat | May 24th, 2007 at 12:30 pm #
It’s certainly important to “get it right” the first time. Not only for coding but in everything we do. This will save our frustrations later on during troubleshooting.
Warm regards
Tiat
P.S: Choose abundance, http://www.AbundanceLaw.com
Tay | May 24th, 2007 at 1:15 pm #
Thanks for the helpful, informative article, Kevin. I will definitely keep all of this in mind!
Brian Heys | May 24th, 2007 at 3:37 pm #
I first started programming professionally almost twenty years ago, and quickly learnt the hard way how commenting your code is absolutely essential.
Nowadays, I automatically put in comments, and sometimes even write comments before I write the code - as a type of ‘pseudocode’.
Ultimately though, I try to write code that is self-documenting, but it’s nice to have comments in there for when I forget and come back to something six months later!