This tutorial assumes you understand Fragments and Collections. If you don’t, read the Creating Page Fragments article first. Once, you’re ready, start by creating a Collection:
-
From the menu for your selected site, click Site Builder → Page Fragments.
-
Create a new Collection named Developing Fragments.
First, you’ll create a Section.
Creating a Section
The list of Collections appears on the left in the Page Fragments page.
-
Ensure that you are in the Developing Fragments collection.
-
Click the New button and select Section.
-
Name your Section Basic Section
You’re now on the Fragment editing page. There are four panes on this screen. You enter HTML in the top left pane, CSS in the top right, JavaScript in the bottom left, and preview the results in the bottom right. The Fragment Editor even comes with autocomplete functionality!
You can look at the three editing panes as if each were writing to a separate
file. Everything in the HTML pane goes to index.html
, the CSS pane goes to
index.css
, and the JavaScript pane goes to index.js
. The preview pane
renders everything as it looks on the page.
A Section defines a work space. Now create a section with an editable rich text area where content can be entered:
-
Add the following code inside the HTML pane:
<div class="banner py-6 py-md-8 text-white" data-lfr-background-image-id="banner"> <div class="container my-lg-6"> <div class="row"> <div class="col-12 col-md-8 col-xl-6"> <h1> <lfr-editable id="01-title" type="rich-text"> Banner Title Example </lfr-editable> </h1> <div class="mb-4 lead"> <p> <lfr-editable id="02-subtitle" type="rich-text"> This is a simple banner component that you can use must provide extra information. </lfr-editable> </p> </div> <lfr-editable id="03-link" type="link"> <a href="#" class="btn btn-primary">Go Somewhere</a> </lfr-editable> </div> </div> </div> </div>
-
Replace the code in the CSS pane with the following:
.banner { background-color:#415fa9; background-position: center; background-size: cover; }
-
Click Publish to save your work and make it available to add to a content page.
As you work, you can observe your changes in the preview pane.
Creating a Component
Components are simple, reusable elements for building parts of a page. Next create a button with a link as a Component:
-
Go back to the Site Builder → Page Fragments page and select the Developing Fragments Collection.
-
Click the New button and select Component.
-
Name it Basic Component.
-
Back in the editor, add the following code inside the HTML pane:
<div class="basic-link-button"> <lfr-editable id="btn00" type="link"> <a href="#" class="btn btn-primary">Read More</a> </lfr-editable> </div>
-
Click Publish to save your work and make it available to add to a content page.
This fragment did not require any CSS. For the button link, no target is provided by default, so the link must be configured when it is added to the page.
From here, the Fragment can be added to a Page. To see this process in action, see the Building Content Pages article.