Introducing a new way to review your PRs.

Read the announcement

frappe / builder

Craft beautiful websites effortlessly with an intuitive visual builder and publish them instantly

View on GitHub

20 documents · Updated Nov 23, 2026

docs / assets-and-block-templates

Assets and block templates

Assets and templates give the visual builder reusable content that can enter a page without starting from an empty canvas. The workspace lets an engineer upload or reuse site-owned media, keep copied content self-contained, save composed blocks for later use, and start whole pages from a shared template catalog. These resources connect to the authored block tree described in Block composition system and are edited within the workspace described in Visual builder workspace.

Resource types

The builder treats reusable page material as three related but distinct resource types. Each type enters the authoring flow at a different level.

ResourceScopeMain useEntry into a page
Site assetImage, video, font, or background media owned by the siteGive a block content that remains available to the siteUpload through an image or background control, or drop a file on the canvas
Saved componentA named reusable component that can be scoped to a pageReuse a component with its own identity and update pathSelect or drag it from the Components panel
Block templateA saved block tree with a name, category, and previewReuse a ready-made section or block arrangementSelect or drag it from the Insert panel
Page templateA complete page with related shared resourcesCreate one editable page or a set of pagesChoose it from the new-page template gallery

The word asset means a file or media reference used by authored content. A component or block template is not an asset file. It is authored structure that may contain asset references.

Site-owned media

Site-owned media is uploaded through the builder and then written into the selected block or style. Image controls support direct URLs as well as file upload. A dropped image becomes an image block unless the target already represents an image or the drop uses a background action. Video files become video content, and font files become site fonts. This keeps media selection part of Property and style editing instead of making the asset panel the owner of block content.

Cross-site paste can leave image and font references pointed at the source site for the first paste. The builder detects those remote references and offers an import action. Importing copies the files into the current site, rewrites the block references, and makes the page less dependent on the source site. Imported fonts also become available in the builder font picker.

References: frontend/…/ImageUploadInput.vue• L1-10 frontend/…/BackgroundHandler.vue• L57-66 frontend/…/useCanvasDropZone.ts• L242-284 frontend/…/importRemoteAssets.ts• L11-28 builder/api.py• L62-98

Reusable components

The Components panel is the workspace surface for saved components. It loads named components, hides components scoped to another page, and supports search, selection, editing, and drag to the canvas. Dropping a component creates a new instance in the page and preserves its link to the saved component so component-level behavior remains separate from ordinary block templates.

This distinction matters when choosing a resource. Use a component when the content has a reusable identity and may receive later component updates. Use a block template when the goal is to insert a starting block tree into the current page.

References: frontend/…/AssetsTab.vue• L1-6 frontend/…/BuilderAssets.vue• L19-47 frontend/…/BuilderAssets.vue• L77-124 frontend/…/useCanvasDropZone.ts• L200-222 frontend/…/webComponent.ts• L1-11

Block template lifecycle

A block template is a reusable block tree stored under a unique template name. It has a category for discovery and a preview image for the picker. The saved tree is a source block: using it creates a new block instance in the page rather than linking the page block to the template record.

Template creation

In developer mode, an eligible ordinary block can be saved as a block template from its context menu. The author supplies a name, category, and preview image. Saving serializes the current block tree and persists the template so it can appear in the Insert panel. A template can later be opened on the canvas, changed, and saved back under the same name.

The template record also owns the presentation data that makes selection usable. Categories group related choices, preview dimensions control the tile shape, and sort order controls the list order. The stored block remains the important product data because it is the content copied into a new page.

References: frontend/…/index.ts• L208-215 frontend/…/NewBlockTemplate.vue• L1-53 frontend/…/blockTemplateStore.ts• L71-95 builder/…/block_template.json• L8-64

Template selection

The Insert panel presents block templates in named categories. It shows each choice with its stored preview and supports name search when the list is large. A click selects a template for template editing in developer mode. A drag carries the template identity to the canvas, where the drop target decides where the new block belongs.

The same drop can insert the template as a child or replace the target block when the author uses the replace gesture. The inserted block then participates in normal selection, layout, property, and history flows. This makes a template a fast composition aid rather than a separate rendering mode.

The following flow shows how a block template moves from storage to authored content.

flowchart LR
    A[Saved block template] --> B[Insert panel]
    B --> C[Select or drag]
    C --> D[Canvas drop target]
    D --> E[New block instance]
    E --> F[Authored page block tree]
    F --> G[Normal editing and save]

References: frontend/…/BuilderBlockTemplates.vue• L1-44 frontend/…/BuilderBlockTemplates.vue• L61-102 frontend/…/useCanvasDropZone.ts• L200-240 frontend/…/blockTemplateStore.ts• L27-69

Template storage

Block templates are stored as Builder records with a serialized block tree and picker metadata. The server validates the preview, moves template-related media into Builder-owned template assets, and exports the record so the template can be restored with the application content. Deleting a template also removes its stored template assets.

The stored template is separate from a page instance. Updating the template changes what future insertions receive. Existing blocks that came from the template are not described as live links to it, so later page edits remain local to the page.

References: builder/…/block_template.py• L17-53 builder/…/block_template.json• L17-64 frontend/…/blockTemplateStore.ts• L71-95

Page template catalog

Page templates are a higher-level starting point than block templates. The new-page gallery presents a blank page, groups of related pages, and the individual pages inside a selected group. A preview helps the author choose without changing the current page.

Template discovery

The gallery reads a catalog of template groups. A group supplies a title, description, preview, categories, and one or more page summaries. The author can filter groups by category, open a group, preview a page at desktop, tablet, or mobile width, and then choose one page or all pages in the group. The gallery keeps the last viewed group and category filter so the picker can reopen near the author's previous choice.

The catalog can include local templates and templates from a template hub. Local pages use the builder preview endpoint. Hub pages use their supplied live preview URL. If the catalog cannot be reached, the author can still start from a blank page.

References: frontend/…/TemplateGallery.vue• L41-79 frontend/…/TemplateGallery.vue• L119-178 frontend/…/TemplateGroupCard.vue• L1-52 frontend/…/TemplatePageCard.vue• L1-44 frontend/…/TemplatePreview.vue• L44-80 builder/api.py• L450-483 frontend/…/template.ts• L4-22

Page creation

Choosing one page asks the server to create a new editable Builder Page from the selected template. The new page receives the template page's authored structure and its related shared resources. The builder then routes the author to that page.

Choosing all pages imports each page in the group and returns the author to the page dashboard. This option is useful when the group represents a small site rather than one isolated screen. Both choices preserve the distinction between a template source and the new pages that the author can change.

The page-template flow connects discovery to page navigation and page persistence:

sequenceDiagram
    participant Author
    participant Gallery
    participant Catalog as Template catalog
    participant Builder as Builder server
    participant Page as Authored page

    Author->>Gallery: Open new-page picker
    Gallery->>Catalog: Load groups and page summaries
    Catalog-->>Gallery: Return previews and choices
    Author->>Gallery: Preview and choose a page
    Gallery->>Builder: Create page from template
    Builder-->>Page: Create editable page and shared resources
    Page-->>Author: Open page in builder

References: frontend/…/TemplateGallery.vue• L172-255 frontend/…/TemplatePageGrid.vue• L10-33 frontend/…/TemplatePreview.vue• L19-32 builder/api.py• L486-584 frontend/…/webPage.ts• L31-34

Template group storage

A shipped page-template group is a coordinated set of page definitions and shared resources. Its pages can use shared components, design tokens, scripts, fonts, and public media. The group is synchronized from committed template data so installs and migrations can restore the same catalog.

Template pages used as catalog sources are not the author's working pages. In production they are read-only sources for the selector. A user-created page that is marked as a template without belonging to a shipped group remains outside this synchronization path.

References: builder/template_sync.py• L1-27 builder/template_sync.py• L70-100 builder/template_sync.py• L164-204

Authored page entry points

Resources enter authored content through two main paths: insertion into the current block tree or creation of a new page from a page template. After entry, the resources use the same page editing and save behavior as content created by hand.

Canvas insertion

The canvas is the boundary where a selected resource becomes page content. A component drop loads a component and creates a linked instance. A block-template drop loads the stored block tree and creates a new instance. A file drop uploads the file before assigning it to an image, video, background, or new media block.

The drop target supplies the parent and position. A normal drop adds content at that position. A replace gesture swaps the target block. After insertion, the content is part of the page block tree and is covered by the canvas, property, and history systems. See Editor canvas interaction, Property and style editing, and Editing state and history for those shared behaviors.

References: frontend/…/useCanvasDropZone.ts• L200-284 frontend/…/BuilderAssets.vue• L104-129 frontend/…/BuilderBlockTemplates.vue• L75-85

New-page initialization

A page template enters the system before ordinary canvas editing begins. The server creates the page and imports the shared records needed by its authored structure. The new page then opens through the normal builder route, where the author can change blocks, styles, assets, and scripts.

This boundary also explains why a page template is not the same as a block template. A block template changes one location in an existing page. A page template establishes the starting content and related resources for a new page or a set of pages. See Page navigation and routing for how the resulting page is opened and selected.

References: builder/api.py• L486-538 frontend/…/TemplateGallery.vue• L180-247 frontend/…/TemplatesDialog.vue• L1-35

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the drag data names shared by the resource panels and the canvas drop handler. A rename can make a tile appear draggable while producing no page content.
  • Keep block-template preview metadata aligned with its category and sort fields. The picker uses these fields to group and size choices.
  • When changing cross-site paste fields, preserve the asset URL collection and rewrite path. Otherwise copied blocks can keep third-party image or font dependencies without a clear repair path.
  • When changing page-template bundles, keep shared components, tokens, scripts, fonts, and media consistent with the page block tree. A page can load while losing part of its intended design system.
  • When changing template-group sync, preserve the difference between shipped template pages and user-created template pages. Reconciliation must not remove user-authored sources.
  • When changing the page-template gallery state, keep category filters, selected groups, previews, and the blank-page path consistent. A stale selection can hide valid choices or reopen the picker in a missing group.

Important failure modes

TriggerConsequenceGuard
A remote image or font cannot be fetched during importThe page keeps the original remote reference or font is not added locallyThe import returns only successful mappings and reports the result to the author
A template preview is missing when a block template is savedThe block template cannot be updatedThe server requires a preview image before saving the record
The template catalog is unavailableThe gallery has no remote choicesThe gallery falls back to the blank-page path
A selected page template has no usable bundleNo editable page is createdThe server rejects the selection and the UI shows a creation error
A block template is dropped without a valid canvas targetNo block is insertedThe drop handler requires a parent or replacement target before mutation
A saved gallery group or category is no longer in the loaded catalogThe picker can show an empty group or stale filterThe gallery resets invalid category state and resolves the active group from the current catalog

Key files

FileWhy to read it
frontend/…/BuilderAssets.vueShows how saved components are filtered, searched, selected, and dragged into the canvas.
frontend/…/BuilderBlockTemplates.vueShows how reusable block choices are grouped, previewed, searched, and dragged.
frontend/…/useCanvasDropZone.tsShows the boundary where components, block templates, and files become page content.
frontend/…/importRemoteAssets.tsShows the high-level contract for making pasted images and fonts site-owned.
frontend/…/TemplatesDialog.vueShows the entry point for the new-page template picker.
frontend/…/TemplateGallery.vueShows page-template discovery, filtering, preview, single-page creation, and group import.
frontend/…/TemplatePageGrid.vueShows the blank-page and page-choice boundary inside a selected group.
frontend/…/TemplatePreview.vueShows how an author previews a local or hub page at several viewport sizes before selection.
frontend/…/blockTemplateStore.tsShows how block templates are fetched, edited, and saved.
builder/…/block_template.pyShows the server-side storage and asset ownership rules for block templates.
builder/api.pyShows the server boundary for asset import, catalog access, and page creation from templates.
builder/template_sync.pyShows how shipped page-template groups and their shared resources are synchronized.