How to add static block to homepage?

What file do I need to edit to add a static block to the homepage?

8 answers

Profile photo of tomc 0.00 $tone March 1, 2012

If you want to add a CMS Static block to a page you need to be somewhat familiar with layouts.

Layouts are stored in:


This directory contains quite a few XML files. These files determine what blocks are shown in the default structural .phtml files.

The first step is to create the block we would like to add to a page. In the Admin section go to the CMS menu and select Static Blocks and create a new block.

Name: Test Block
Identifier: test_block (this is what we will refer to in the code)
Status: enabled
Content: This is some text.

The second step is to find the XML file containing the layout we wish to modify. Let’s say we would like to make this block appear only on the Customer Account page (the customer dashboard). We would find the customer.xml file and add some text to it. There are a few things to know about layouts first.A very basic structure is something like this:


/** If the code you are placing is under default it will appear on all pages unless specifically <unset>, this allows you to put something under the reference tag and have it appear on every page. **/
/** The reference name will refer to what section we are placing the block in, i.e. if the name="header" it will be in the header section.  Likewise saying name="content" will place it in the main content section **/
<reference name="header">
/** Some block we have added **/ 

/** If a section is under a different name such as customer_account it will pertain only to that section **/
<reference name="header">

Now if we place our code in the customer.xml file under the section . . . .


Customer account home dashboard layout

        <update handle="customer_account"/>
        <!-- Mage_Customer -->
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        <reference name="content">
            <block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml">
                <block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/>
                <block type="core/template" name="customer_account_dashboard_top" as="top" />
                <block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>
                <block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
                <block type="customer/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/>
                <block type="core/template" name="customer_account_dashboard_info1" as="info1" />
                <block type="core/template" name="customer_account_dashboard_info2" as="info2" />
/** ------------------------------------------------------------------------------------------------------------------------------------- **/
            <block type="cms/block" name="cms_test_block">
                <action method="setBlockId"><block_id>test_block</block_id></action>
/** ------------------------------------------------------------------------------------------------------------------------------------- **/


. . . . it will appear at the end of the Customer Dashboard.

Note the <block_id></block_id> tags, whatever we put there will correspond to the identifier of our block. The name of the block doesn’t matter, you can name it anything you like but it makes sense to make it relevant to the block.

If we place the block under a default section then it will appear on all pages.

To limit the block to only the home/front page, . . . . go to “CMS -> Manage Pages -> Home Page” in the admin >> select “Custom Design” from the left >> and add your static block reference code to “Layout Update XML”.

Hope this gets you started!

Profile photo of Sean Taylor 0.00 $tone March 1, 2012

Thanks. So if I created a static block and called the block title is "Welcome" and the Identified is "welcome" then what should the code be that I place inside Layout Update XML?


This question is now closed

Written By