Skip to content
跨境独立站开店
Guides

How to create a custom landing page template using Liquid

"You can read this in 3 minutes." At some point, online entrepreneurs need landing pages to promote their products, capture marketing leads, and launch campaigns.

Check Shopify registration offers in your regionSee current offer

Online entrepreneurs will eventually need landing pages to promote their products, generate marketing leads, and launch campaigns.

*Please note that this article contains outdated information due to a 2021 update. While the basic concepts of Liquid explained in this article remain unchanged, please check the developer's website (in English) for the latest information.

Online entrepreneurs will eventually need landing pages to promote their products, generate marketing leads, and launch campaigns. Developers can leverage their expertise to support these client needs.

User-centered design is essential for landing pages targeting specific audiences. Developers must create layouts and page functionality with the client's users in mind.

With well-thought-out static sections, you can build customizable landing pages in Shopify. Clients can insert their own content here. This means developers can focus on page design, while clients can decide which products and copy to display on the landing page.

Creating landing pages with Shopify is also beneficial for developers who need a portfolio site to acquire new customers. Add case studies, past projects, and your skills to custom sections.

This article will show you how to customize existing themes and create landing page templates that allow clients to insert store content. We'll also cover how to create flexible landing pages using Liquid tags and section settings, and how to offer clients options during campaigns.

Create a custom page template

The first step in adding landing pages to a theme is creating a custom Liquid template file for a specific campaign. Using alternative templates allows you to create a Liquid file specifically for a particular landing page. This can be assigned to the page by the client from the admin and can also be customized in the theme editor.

When you add a new template in the template editor on the administration screen, the editor automatically loads the default template code.

When you create a new template file in the template editor in the administration panel, the theme's default template is automatically generated.

In this example, we want the additional elements to appear below the input text, so the new section will be contained under the Liquid object {{ page.content }}. However, let's experiment with different positions for the content and sections to find the best fit for the client.

NOTE: If your client wants to host multiple landing pages, you will need to create a different page template and unique sections for each landing page. The known limitation of sections is that changes made to one section affect the entire iteration of that section. Therefore, you need to create separate sections to avoid changes in one section spreading to other versions.

Add content to your landing page

Next, you need to have a clear understanding of what content the client wants to include on their landing page. This could be a specific product, a collection they want to promote, or a blog post they want to attract an audience to.

In this example, we want to focus on collections and add a featured collections section to the page. Most themes already have a featured collections section, which can be accessed from the theme editor.

These existing sections are usually dynamic sections, so you can add them to your homepage, but you can also add them to other pages as static sections. Similar to snippets, you can put sections into your template files using the `SectionLiquid` tag. This is commonly used for static sections like headers and footers, but it can also be used for landing pages.

The theme used in this example is Narrative. It already has a dynamic section that displays the featured collection. Once you find this Liquid file in the sections folder, copy its code into a new section and give it an appropriate name, such as fall-featured-collection.liquid.

Next, remove the preset from the section settings and convert it to a static section. This is the JSON array at the bottom of the section.

Now you can add it to your custom page template using the Liquid tag {% section 'fall-featured-collection' %}.

See also: Creating your first Shopify theme section

Using Liquid's control flow tags in section settings allows you to create functionality that toggles visibility based on the section's configuration. The rules you might apply here would look like this:

{% if section.settings.show_newsletter == true %}

code for newsletter

{% endif %}

"type": "checkbox",

"id": "show_newsletter",

"label": "Show newsletter sign up",

"default": true

Add a CTA to your landing page.

A common feature of landing pages is the CTA (Call To Action) button. Clients can use this to guide visitors towards actions such as creating an account, accessing content, or purchasing specific products.

Many themes don't typically have a section for calls to action (CTAs), but you can create your own custom section.

While existing themes don't natively support CTA sections, it's important to assign a default class name when creating them to ensure consistent styling across the theme.

In this example, we're using Narrative, but a secondary-style button would fit this page better, so we'll use the class name btn--secondary when designing this section. The class names and IDs you use will vary depending on your theme.

I added a header above the CTA button in this section, allowing the merchant to add text. The copy and link destination of the button itself can be determined in the section settings of the theme editor. Once these settings are complete, the code for the CTA section will look like this:

Again, we'll add a setting to this section that allows clients to toggle the display on and off. This gives merchants the flexibility to decide what important elements should be included on their landing pages.

In this section, we've added a text field above the button so that clients can add copy whenever needed. This is useful if you want to add additional supplementary guides or other information to the CTA.

Put everything into a custom page template.

Now that we've created several static sections, we'll add them to the template for the custom page we just created. As mentioned above, to add a section to a template, we use the section tag (e.g., {% section 'fall-featured-collection' %}).

Once you add section tags to the three sections you've created, the page.fall-landing-page.liquid template will look like this:

Now, when clients create landing pages, they can select a specific template from the admin panel.

Hide the header and footer from the landing page.

One option when designing a landing page is to remove the header navigation and footer. This limits the options available to visitors, allowing you to focus on the page content and call to action (CTA).

You can also use Liquid's control flow tags to set conditions that prevent newly created landing pages from loading their headers and footers. This can also improve page loading speed.

In this example, we use the `unless` tag to ensure the header is included only if the current page is not a landing page. This condition can also be written in the `theme.liquid` file. Here, the header is included as `{% section 'header' %}`.

To activate this condition, the `unless` statement targets the template filename `page.liquid`. The `contain` operator is used to ensure that the header is only loaded if the template title does not contain "landing-page".

Here is the code after configuration.

{% unless template.suffix contains "landing-page" %}

{% section 'header' %}

{% endunless %}

Similarly, the footer can also be wrapped in an unless statement within the same theme.liquid file.

{% section 'footer' %}

Once the above is implemented, the header navigation and footer will no longer be displayed on landing pages, and the same will be true for other files with "landing-page" in their title. However, the header and footer will still be displayed on other storefront pages.

Customizing landing pages

Ultimately, the client will add products, registration forms, CTA buttons, and other elements to this landing page via the theme editor. The page selector helps users access specific landing pages and edit their relevant settings.

Once you set up the type of static section your client wants on the landing page, they can then incorporate collections, products, blogs, and other necessary content into the page. This non-bourgeois approach allows clients to decide which content they want to emphasize, while developers can focus on visual design and creating high-converting landing pages.

If you want to understand how landing pages look and feel to users, you can check out some examples I've created here.

Make your landing pages creative

Feel free to experiment with different approaches, such as exploring the native sections of existing themes or creating entirely new sections with unique features and layouts. You can also customize existing dynamic sections to better suit your landing pages.

As mentioned above, adding section display options allows clients to hide elements they don't need on their landing page. This flexibility will be important when clients are launching their landing pages.

Grow your business with the Shopify Partner Program. Whether you offer marketing, customization, web design, or development services, the Shopify Partner Program will guide you to success. Joining the program is free, offers revenue-sharing opportunities, and provides access to a wealth of tools to grow your business. Join our passionate commerce community today!

read more

  • An overview of Shopify's template language, Liquid.
  • [How to Use Shopify] Opening an Online Store: Basic Setup
  • How to create a members-only website with Shopify
  • 30 Stylish E-commerce Sites Built with Shopify, Selected by Designers
  • This guide explains how to set up and specify a domain name for your online shop.
  • Key points when creating your first Shopify Theme Section
  • 33 Recommended Shopify Themes by Industry
  • How to get reviews for your Shopify app
  • How to create a globally compatible theme using translation keys

FAQ

What is a customizable landing page?

Can you create landing page templates?

How do I add sections to a custom template?

Share this article

  • Share on Facebook
  • Share on X
  • Share on LinkedIn

Related reading

View all
View offer
Shopify

Start free and explore current offers

Visit Shopify for trial duration, eligible plans and promotions available in your region.

Register free with ShopifyAffiliate disclosure