We use cookies to make your viewing experience better. By accepting you consent, you agree to our Cookie policy

Accept
Improve your Craft CMS skills

How To Create A Homepage Using Craft CMS

10 min read
Shape April 2022 HR 189

Struggling to build an engaging homepage that converts? Crafting a high-impact homepage in Craft CMS is easier than you think. This guide will walk through creating a flexible, customizable homepage to wow your site visitors. Learn how to quickly add content modules, tweak layouts, and publish changes using Craft's user-friendly interface. Expert tips will help you maximize conversions and optimize for search - transforming your homepage into a powerhouse lead generator.

To create an engaging homepage in Craft CMS, add a Homepage section, configure SEO settings, build a Twig template, populate entries with modular content blocks, and leverage draft/live workflows to safely preview and publish updates. Craft's user-friendly interface makes building, editing, and optimizing a homepage easy.

Installation and Configuration of Craft CMS

Downloading and Installing Craft CMS

To get started with Craft CMS, first you'll need to download it. The recommended way is using Composer, which is a dependency manager for PHP.

To install Composer, go to getcomposer.org and follow the instructions for your operating system. Once installed, open a terminal window and run:

composer create-project craftcms/craft

This will download and install the latest version of Craft into a new folder called craft.

After Craft is downloaded, navigate to the web-based installer by going to yoursite.com/admin. The installer will walk you through creating a database, setting up the site name, admin account and more. Make sure to save your admin password somewhere safe!

The whole install process should only take a few minutes. And that's it - Craft CMS is now ready to start building your site!

General Configuration Settings

Once Craft is installed, you'll want to review some key configuration settings to get your site properly set up.

In the control panel, go to Settings ➜ General to edit all your general config options.

Some important settings here include:

  • Site Name - This controls the name displayed in the CP and on the front-end.

  • Base URL - Set this to your site's URL. This allows Craft to properly generate links.

  • Timezone - Choose your site's timezone here. This will control date/time output.

  • Default Language - Pick the primary language for your site content. You can add more languages later if needed.

The Images and Files sections are also important to configure. Here you can set the location where uploaded images and files should be stored, what URLs should be generated, and more.

It's a good idea to review all the general settings and tweak as needed for your particular site. This will help avoid any configuration issues down the line.

Email Settings in Craft CMS

To enable Craft CMS to send emails, such as for password resets or contact form submissions, you need to configure email settings.

Go to Settings ➜ Email to set up your email preferences. There are a few key options:

  • Protocol - Set this to SMTP or Sendmail depending on your server setup. SMTP is recommended.

  • SMTP Host - Your SMTP host (e.g. smtp.yourdomain.com). Required for SMTP.

  • SMTP Port - Typical ports are 25, 465 or 587. Check with your host.

  • SMTP User/Password - Credentials if your SMTP host requires authentication.

  • Sender Name - The name emails appear to come from.

  • Sender Address - The email address your system emails are sent from.

Once your email settings are configured, Craft will be able to dispatch emails for things like new user registration, password reset requests, and contact form submissions.

It's a good idea to test email sending is working properly after configuring your settings. You can do this by triggering a password reset email to yourself or submitting a test contact form.

Proper email functionality is vital for any web application, so taking the time to get your email settings right in Craft CMS will ensure things run smoothly. Let those emails flow!

Creating a Homepage in Craft CMS

Adding a Homepage Section

The first step in creating a homepage in Craft is adding a new section dedicated to the homepage content.

To add a section, go to Settings → Sections in the control panel and click the "New section" button. Give your section a name like "Homepage".

Next, choose your desired entry type. You can keep it simple with just a Single section, or expand it to Channel or Structure if you want multiple homepage entries.

Select the entry type that makes sense for your needs. Single is best for a typical single homepage. Channels allow multiple homepage entry versions. Structure gives you nested entries.

Now it's time to add any custom fields you want on your homepage entries using the included Field Layout Designer. You can create fields for headers, body content, images, buttons and anything else you want on the page.

Organize your fields into tabs and field layouts. Try keeping it logical, with similar fields grouped together. This will keep your editor nice and tidy.

With your section added and fields configured, the content structure for your homepage is all set!

Configuring the Homepage Section

With your Homepage section created, let's look at configuring some key settings.

Under section settings, the Entry URL Format and Entry Template settings are very important for SEO.

Set your Entry URL Format to something like home to create a simple /home slug.

For Entry Template, use home or index to set the default template path.

This will allow your homepage to be accessible at a clean URL like www.yoursite.com/home or www.yoursite.com/index.html.

You can also set a Title Format if you want your homepage title tag generated automatically. For example, {siteName} | {entry.title}.

Take time to review all the available settings to dial in your homepage section. Things like enabling versioning and defining workflows.

Optimizing these settings from the start will ensure your homepage has a solid foundation as you build out the rest of your Craft site.

Building the Homepage Template

Now that your Homepage section is configured, it's time to build the actual template file for your homepage.

In your templates folder, create a new file called home.twig or index.twig - this should match the Entry Template filename you set earlier.

In the template, output your various homepage fields using Twig tags and the entry variable:

<h1>{{ entry.heroTitle }}</h1>

{{ entry.bodyContent }}

{% for block in entry.bodyBlocks %}

{{ block }}

{% endfor %}

You can use Twig tags, variables, loops, logic, and more to construct your template markup and output your field content.

For images you'll want to use the |image filter on your field to get properly formatted img tags:

{% set heroImage = entry.heroImage.one() %}

<img src="{{ heroImage.url }}" width="{{ heroImage.width }}" height="{{ heroImage.height }}" alt="{{ heroImage.title }}">

Take advantage of Twig's power and flexibility to build out your homepage template exactly how you need it.

With your homepage section, settings, fields, and template in place, you now have the foundation for displaying dynamic content on your Craft CMS homepage!

Adding and Managing Homepage Content

Creating Homepage Entries

Once your Homepage section and template are ready, it's time to create your first homepage entry and add content.

Go to the Entries page, click your Homepage section, and choose "New entry". Give your entry a title and slug if desired.

Now it's time to populate your custom fields and content modules with all the data you want displayed. Add your headings, text, images, videos, buttons - all the content that builds up your homepage.

For complex modules like a hero slider or testimonials carousel, create your desired entries in those sections first. Then relate them to your homepage entry using selection fields or relational fields.

This modular approach allows non-developers to easily build up complex homepage layouts by piecing together content from different areas of the site.

As you add and arrange your various content modules, use the Preview button to see how your homepage is shaping up. Make sure everything is displaying as expected before moving on. Once your fields and modules are populated, your new homepage entry is ready to go live!

Editing and Updating Homepage Content

A key advantage of Craft CMS is how easy it makes editing and updating content after it's live.

To modify your existing homepage content, simply go back to the original entry and make your changes - update text, swap out images, add new modules, etc.

All changes get tracked as new revisions, allowing you to revert to a previous version if needed. Use the Revisions tab on your entry to browse old revisions.

For major homepage redesigns, it may be best to duplicate your live entry and create an updated version that can be reviewed before going live.

This creates an easy way to stage your changes on a separate Draft entry and switch them over once finalized. You can duplicate entries from the Entries index page.

No matter if you tweak modules directly on your live entry, or through new Drafts, Craft provides a flexible authoring workflow.

Publishing and Previewing Homepage

Before going fully live with homepage changes, Craft offers robust preview and publishing capabilities.

By default, newly created entries start as Drafts. Use the Publish button on your entry to push it live on the front-end.

Changes made to existing entries must also be published before they will go live. Craft maintains both live and draft versions.

To preview how your published changes will look, use the Preview button. Or, enable Drafts on the front-end to see draft content.

The Preview window lets you quickly view how your homepage will appear across all device sizes. Check mobile, tablet, and desktop views.

For full front-end testing, publish a Draft entry then verify how it looks across your actual site pages. Toggle drafts off again to revert back.

With preview abilities and draft/live workflows, Craft provides the essential tools for safely managing your live homepage content.

Shape April 2022 HR 202
Andy Golpys
- Author

Andy has scaled multiple businesses and is a big believer in Craft CMS as a tool that benefits both Designer, Developer and Client. 

Share
Feedback
Show us some love
Email Us
We usually reply within 72 hours
Agency Directory
Submit your agency
Affiliate Partners
Let's chat