This is another technical post in which I’m ‘getting my geek on’ as a musician/entertainer come tech-geek. I brand myself as just that: It’s what makes me unique and differentiates me from most other musicians.
Every now and again I develop something really nerdy and I just have to post about it on my site no matter what. – This is one of those occasions.
– But it’s not just me and me alone who needs technical knowledge. All musicians & entertainers in this 21st Century age need to know how to market themselves. Whilst it’s true that some musicians don’t need to market themselves as their PR is all handled by their management as a part of their record deal or recording contract, the percentage of such musicians is in the minority compared to the multitude of indie artists who are all doing their own marketing. – It’s those indie artists who could use some technical help from time to time with regard to their online presence; and this website sets out to kill two or more birds with a single stone by showing out my image as a techy geek musician, while at the same time in part helping out other musicians with technical issues where possible to some extent.
At this point you may be asking
‘How does creating an HTML sitemap that’s not a plugin help anyone in any way? That is just so ultra-geeky, and yeah it shows you up as a tech-nerd for sure; but what good is it to me? If I need an HTML sitemap on my ( WordPress self-hosted) website I can just go find an HTML sitemap plugin and install it.’
And you’d be 100% right in saying so: For the sake of speed that’s all you’d need to do.
What you haven’t considered, though, is that every plugin puts extra load on your database and slows down your website’s load time just that bit extra. The more things you can do without the help of a plugin the better at the end of the day.
If you take a look through the vast WordPress Plugin Repository you see a myriad of plugins for pretty much everything imaginable. You might even find a few that have been updated in the last year too. If you used every plugin that was compatible with your version of WordPress your site would never load fully. Try cutting that down to 100 plugins and your site would still take ages to load.
As a musician/entertainer you want your site to be snappy and not take forever to load too; and so you want to avoid plugins as much as possible also. If you can get away with creating the desired function without using a plugin then do so.
You can have an HTML-sitemap on your WordPress site without using a plugin: This article shows how it's done. Click To Tweet
So when you go and install that HTML sitemap plugin it writes new tables to your database and consumes server memory + processor-time in executing the new PHP routines.
The method I’ve come up with hardly touches your database in comparison, and uses fewer resources because the code is basically simplicity itself.
How To Do It
The way to accomplish this fete is to utilise a template rather than a plugin, to generate the HTML sitemap’s output. Why a template? Because you can run PHP routines on a template – whereas that’s not possible on a page (Unless you use a plugin, which defeats the point of the exercise.).
First of all then we need a template. I’ve used this phrase often before and wouldn’t be surprised if it were to become clichéd: –
The best way to start creating a new template is, first, to copy an existing template.
This is actually fairly easy to do. You want to look for a template file in your theme that generates a single page. Depending upon the theme you’re using that may possibly be the file page.php, or content-page.php, or something similar. When you find it, make a copy of it and add it to your theme’s files as inventory.php, or content-inventory.php .
How exactly you pull this off will depend upon your theme and how it works. I just attempted to write two clear sets of instructions for two of the main types of theme. After an hour I realised that the task was going to take ‘forever’, so I decided to deal with the basics only.
If you’re working with single.php only, and there is no other file involved in page-creation referenced from that template; ensure your copy template begins with something very similar to: –
It may well be best to keep the header to the bare minimum, so you may like to create a stripped-down header and use something like the following to call it: –
Depending upon your theme you may need to change the lines: –
and create a content-inventory.php file by copying the content-page.php file, renaming it to content-inventory.php, and carrying out the following inside that file.
The HTML sitemap template we’re creating will need to do some basic functions in PHP.
At this point in the article, to save time and a load of explanation covering many reams and pages of text; I’m suggesting that you use the PHP code from this site as follows: –
Frame & Title
Site Article Inventory: –
Call & Display Number of Posts
Number of Posts So Far:
List Blog Posts
Listing of the latest post titles. ( Maximum 100 )
- Posted on:< ?php echo get_the_date(); ?>
< ?php $author = get_the_author(); ?>Author: < ?php echo $author; ?>
< ?php endwhile; ?>
Call & Display Number of Pages
Number of Pages So Far:
List Page Titles & Dates
Listing of the page titles ( All )
with publication dates
Briefly the above works as follows: –
There are a few css references in the above code. Here is the corresponding css code in the colours used to display the page on this site. (Adjust at will to suit your own site.)
Because this template is just that – a template; lacking anything in the way of special SEO-ability – you won’t find the content that it presents as a page to be top-ranking on Google by any means.
Having said that I very much doubt that you’ll lose many if any brownie-points from Google for displaying it. What you have accomplished, however, is you’ve created a template that does the work of a plugin and that uses less resources as a result. – Now that’s progress! – Google should at least reward you with a single Brownie-point for effort.
As for copyright; well I don’t claim any copyright on the above PHP, or any other part of it; although you might like to remember that I wrote it and demonstrate that fact by giving me a mention if you decide to use it or your own version of it for your own purposes.
…And, in a nutshell, that is basically that: I’ve tried to keep it as non-technical as possible; although I may have failed in that way. If it helps you or gives you ideas then so much the better: that is the aim of this website after all.
To see this non-plugin working on this very site; go here and see for yourself.
- 'Simply one more edifying post. - Enjoy.