index.php is the only file that Joomla insists is present in a template.
It is where all the main logic of a template is stored and has to specify all the module and component display code. Although any JavaScript code would also be referenced here, it is probably a bad idea to include formatting and layout directives in this file.
A minimal Joomla index.php would look something like:
<html>
<head>
<jdoc:include type="head" />
</head>
<body>
<h1> This is a Joomla heading entry</h1>
</body>
</html>
Although Joomla will run this satisfactorily, it will actually produce no visible output in the browser. So, what is actually happening?
The “jdoc” tag sets up a call to JDocument, which is a PHP class within the Joomla framework. The modifier ”:include” specifies a method within this class. Generally speaking, the include method is used for all output within Joomla templates.
This provides access to the generated document text in a structured fashion. The most useful properties of this object are…
JDocumentHTML methods include:
Within a Joomla template, $this always returns a reference to a current instance of JDocumentHTML. Hence the statement
<?php echo $this->template;?>
will print the current template's directory path.