惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
I
InfoQ
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
量子位
博客园 - 叶小钗
月光博客
月光博客
IT之家
IT之家
G
Google Developers Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享

CloudCannon Blog

Building with AI: Git-based vs headless vs traditional CMS CloudCannon + Astro: performance meets powerful content management Introducing the Astro Component Starter Introducing Jetstream — built on the Astro Component Starter Why we switched to the system font stack Redesigning CloudCannon’s docs with Diátaxis, Lume, and Pagefind Make content editing more visual: upgraded Editable Regions How Configuration Mode makes building editing interfaces easy Your hosting just got an upgrade (and a price cut) Custom testing domains for professional branding Keep your content consistent with input validation Managing multilingual content in CloudCannon Simplify team publishing with conflict resolution and domain tools Open Beta: Publishing Conflict Resolution Getting started with CloudCannon and Astro: Bookshop, components, and live editing Welcome to the CloudCannon Community! Omnichannel delivery is just marketing spin from API-based CMS companies Getting started with CloudCannon and Astro: Snippets and Collections Managing digital assets in CloudCannon: a guide to smart asset storage Understanding CloudCannon's branching workflows and Projects: a complete guide What is a static website? CloudCannon’s 2024 wrapped Getting started with CloudCannon and Astro: WYSIWYG blogging Jamstack vs. WordPress: reasons to make the change The top five static site generators for 2025 (and when to use them!) Free Jekyll themes for 2025: ten great community options Eleventy (11ty) vs. Hugo How to set up WYSIWYG editing with MkDocs Material The rise of static-first websites: why major brands are making the switch Watching your Core Web Vitals on Jamstack
Making a Page Builder with CloudCannon
2021-10-07 · via CloudCannon Blog

Page builders give editors an intuitive and easy way to manage and build websites. All editing can be done within CloudCannon's Visual Editor in real time.

Visual data previews are enabled with the use of Bookshop. Bookshop is a component development workflow for static websites which currently supports Astro, Hugo, SvelteKit, Jekyll, and Eleventy.

Bookshop helps you to create a component-based file structure, which works out of the box with CloudCannon's array structures. (See our documentation on array structures for more information.) This setup allows CloudCannon to immediately re-render any changes to page components and edits within the Visual Editor.

Getting started Direct link to this section

Download or fork our example repositories ( Jekyll, 11ty ) from GitHub. If you've downloaded the example website you will need to unzip it. With your terminal, change directory into the website. e.g. cd ~/desktop/page-builder-example-jekyll/

To run the website locally run the following commands:

  • Install (11ty): npm i
  • Install (Jekyll): npm i && bundle install
  • Run the stack: npm start

Your website can now be opened in a web browser by visiting the URL listed in your terminal. Once the website is built and uploaded to CloudCannon you will be able to use the live editing features.

Directory structure Direct link to this section

After unzipping or cloning the example website you will see the following directories:

  • .cloudcannon
    (This is a hidden directory so it will only be visible if you open the website with your text editor)
  • component-library
    • bookshop
    • components
    • shared
  • site

These are all necessary for Bookshop, and enable live editing with CloudCannon.

.cloudcannon contains a pre-build script that tells CloudCannon to install any dependencies, and run the Bookshop script. Without this, live editing on CloudCannon won't be possible.

component-library has three directories which contain the website components, shared styles, Bookshop config, etc. The components directory is where all of your components should be built. Each component has its own folder which holds everything relating to it:

  • component.<framework>
    The component template
  • component.bookshop.toml
    The configuration/front-matter settings for the component on CloudCannon
  • component.scss
    The styles for the component

This gives you an easy to manage component library with self-contained components. Bookshop automatically compiles the styles on build, and turns all components into array structures for CloudCannon. You don't need to worry about adding, including, or importing these files anywhere.

site contains all of the Jekyll or Eleventy files for your website. You can build your website as you would with any other site within this directory. Your site is separated from Bookshop for better organization.

Creating new components Direct link to this section

Page components give editors a collection of different content types/layouts that can be used to build pages. Bookshop only enables live editing for components, so if you have other hard-coded content structures these will not live update when modified via front matter.

When creating new components they should be added to a folder with the name of the component, inside the component-library > components folder. This component folder must contain the three files mentioned in the Directory structure section (component template file, component TOML file, component styles).

An example of a new component would look like this:

- component-library
   - components
      - my-new-component
         - my-new-component.bookshop.toml
         - my-new-component.jekyll.html
         - my-new-component.scss

To help with this process you can run the Bookshop gen command, which will create a skeleton for any new component:

npx @bookshop/gen --name my-new-component

Using components Direct link to this section

To give editors access to components, you need to add the content_blocks key to the front matter of any page you want components to be accessible on.

Example:

index.html
---
title: Welcome to our website
content_blocks:
---

Once the website has been built on CloudCannon, content_blocks will be shown as a button within the Visual Editor that lets you choose which components to add to the page. content_blocks links to the structure listed in the TOML file of each component, which auto-populates the component picker.

Components that get added to the content_blocks array are rendered onto pages with the following code, which is located in the default page layout.

<body>
<main>
<!-- The `page` include loops through all content_blocks and renders them.
Using a bookshop tag here means that live previewing will catch new components. -->

{% bookshop_include "page" content_blocks: content_blocks %}
</main>

<!-- This tag registers live previewing on CloudCannon. -->
{% bookshop_live _cloudcannon/bookshop-live.js %}
</body>

page.<framework> (referenced in the codeblock above)

{% for block in content_blocks %}
<div class="cms-editor-link"
data-cms-editor-link="cloudcannon:#content_blocks[{{ forloop.index0 }}]">

<span class="cms-editor-button"></span>

{% bookshop {{block._bookshop_name}} bind: block %}
</div>
{% endfor %}

You can modify the default page layout in the example website if you want to change the way components are rendered.

Uploading/syncing to CloudCannon Direct link to this section

To get your new Bookshop site on CloudCannon you need to log in to your account and create a new site. You can choose to sync a repository, upload a folder, or upload the zip downloaded from this post.

If you're uploading a folder, make sure the .cloudcannon folder is checked when selecting files to upload. If this is unchecked you will get build errors and won't be able to use the live editing features.

Summary Direct link to this section

After learning the basics of how Bookshop can be integrated into a website, you should now have live editing for components in CloudCannon's Visual Editor. The structure in the example website is a good base for starting, or converting any static website to a Bookshop component-based website. To dive deeper into Bookshop and how it works, check out the Bookshop Guides.

You can also use Bookshop in a theme to save duplicating components and styles across websites that use the same themes or layouts. We do this for our Bookshop templates, which are free for anyone to use and modify.

For further reading on themes, see our other posts on creating themes with GitHub, or with Gemfury.