ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to Create Your Own Template for Joomla

Updated on August 1, 2011
Be sure to save your files exactly as shown so that they are compatible with Joomla.
Be sure to save your files exactly as shown so that they are compatible with Joomla.

Joomla is a powerful open-source content management system that can handle a magnitude of sites. I have personally created a variety of sites that range from simple 5 page websites to full e-commerce websites. Although there are several options for free Joomla template downloads as well as many outstanding paid templates; sometimes it’s easier to create a template from your own thoughts.

There are a few prerequisites to be able to successfully create and upload your own template. The first is that you need to know how to create a page utilizing HTML and CSS. You can choose to download a CSS based template and make changes from there, however you must have enough understanding to be able to know where your <div> tags are and what the purpose is of those tags. You do not need to complete the website, you just need to have one page that will be used as the template. Joomla has a specific file management system as well as file naming that you must adhere to when creating the template.

As far as file management, you will need to make sure you have within your main folder a subfolder labeled “css” where your style sheet will be saved, and a subfolder for “images” where all of your images for the template will be saved. Your HTML file will be saved in your main folder at the same level as your two subfolders. Your main style sheet must be named “default.css”. It is easier when you are creating the HTML CSS template to set your file management up this way before you begin creating. If you are using a downloaded template, I recommend changing your file structure and paths before getting started on changes in the code.

Remember, accessible website design is the separation between content and cosmetic, meaning that a logo can be in the HTML with an alt tag because it is relevant information to a viewer but background images should really be included through your style sheets.

To reformat your HTML document for Joomla we must make it a .php file and replace some of the code. First, make a copy of the folder that you have created for your file management. It is always good to have the original file to fall back on in case you need to try again. Preview your HTML file in your browser and take a screenshot. Rename that screen shot “template_thumbnail” and save it on the same level as your HTML file.

To change your HTML document to work as a successful PHP document do the following:

  1. Open your html file in your text editing software and save as “index.php.
  2. Replace the everything from the top to </head> with this:

<html xmlns="http://www.w3.org/1999/xhtml">

<?php defined('_JEXEC') or die ('Restricted access'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >

<head>

<jdoc:include type="head" />

<link href="<?php echo $this->baseurl; ?>/templates/system/css/general.css" rel="stylesheet" type="text/css" />

<link href="templates/<?php echo $this->template; ?>/css/default.css" rel="stylesheet" type="text/css" />

</head>

  1. All of the content within your div tags will need to be deleted and replace with a piece of PHP code to change it to be a modular position in Joomla.  This will be similar to this: <jdoc:include type="modules" name="header" style="xhtml" />  Now the header of your template, most likely where your logo and banner are, will be a position in Joomla. This is convenient if you want to put a search component in your “header” position.
  2. From there continue through your code and delete everything except for your divs and replace that with the Jdoc command. Make sure to change the “name” in your jdoc command for each position.
  3. If you have a part in your template that is specifically for text, to show text in Joomla in a modular position you need to put this code instead:

        <jdoc:include type="message" />

 <jdoc:include type="component" />

  1. Next you need to create an .XML install component to include with your template package. Below is the template that you can fill in the information. Make sure to name this templateDetails.xml

<?xml version="1.0" encoding="utf-8"?>

<install type="template" version="1.5">

<name>???</name>

<version>???</version>

<creationDate>???</creationDate>

<author>???</author>

<authorEmail>???</authorEmail>

<authorUrl>www.dappledesignsonline.com</authorUrl>

<copyright>(c) ???</copyright>

<license>GNU/GPL</license>

<description>???</description>

<files>

<filename>favicon.ico</filename>

<filename>index.html</filename>

<filename>index.php</filename>

<filename>templateDetails.xml</filename>

<filename>template_thumbnail.png</filename>

<filename>css/default.css</filename>

<filename>css/index.html</filename>

<filename>images/index.html</filename>

<filename>images/img01.jpg???</filename>

</files>

<positions>

<position>header???</position>

<position>content???</position>

<position>menu???</position>

<position>sidebar???</position>

<position>footer???</position>

</positions>

</install>

Although it is not required, you can add a favicon in your template which will show up in the URL when you load your website. If you chose not to include this you will need to delete <filename>favicon.ico</filename> from your template details. You can create a favicon easily at www.favicon.cc. Also, you will notice that there is an HTML file in all folders… this is important for security reasons. Create an HTML file that consists only of a white background and include these files in each folder: template folder, CSS and image folder. When someone tries to view your files, only a white screen will greet them.

Now that you have all of the components in your folder, you need to compress your folder so that you can upload it to your website. Once you have your zip file you are ready to upload: sign into the back end of your Joomla site and go to Install/Uninstall. Choose your zip file and upload it. You will receive a message stating that there was a successful upload. From there assign your template in your template manager and your template will successfully be created, uploaded and assigned to your website.

Although there are several options for commercial templates, as well as free templates, it is important to know how to create and successfully upload your own. This opens the opportunity for future projects without being confined to someone else’s vision.

Comments

    0 of 8192 characters used
    Post Comment

    • dappledesigns profile imageAUTHOR

      dappledesigns 

      6 years ago from In Limbo between New England and the Midwest

      I personally find creating templates for Joomla much easier than Wordpress. This is mostly due to the fact that I have worked so much with Joomla and am very comfortable with the "rules" - where with Wordpress I am about a year of experience behind Joomla.

      I prefer Joomla overall because I feel like it gives me a lot more room to create sites easily without having to bypass the "blog" features.

    • BlissfulWriter profile image

      BlissfulWriter 

      6 years ago

      Do you find creating templates in Joomla easier? Or in Wordpress easier?

    • profile image

      Praveen Singraur 

      6 years ago

      Check this helpful link too it having good post on creating custom template in joomla....

      http://mindstick.com/Articles/9d8fe61d-91bf-4e24-b...

      http://net.tutsplus.com/tutorials/php/how-to-build...

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)