Blocks

Add/modify blocks

Disable or enable

/config/_default/params.yaml

All blocks are available by default but if you want hide or add your blocks, you can do it:

admin:
  blocks:
    # Array of available blocks
    enable:
      - alert
      - cta
      - editorial
      # …

Personalize fields

/config/_default/params.yaml

admin:
  blocks:
    # Array of available fields for a block
    # e.g with paragraph block
    paragraph:
      fields:
        - title
        - text_markdown
        # …
See Hugolify fields in repository

How to create a block

Fields allowed

Add a HTML block file contains fields (e.g. alert.html).

layouts/
└── partials/
    └── admin/
        └── blocks/
            └── fields/

Keep these files in layouts/partials/: hugolify-admin v1 looks for them there, not in layouts/_partials/.

Content of fields:

{{- $fields := slice 
  "text_markdown" 
  "state" 
  "background" -}}
  
{{- $fields = partial "admin/func/GetFields.html" (dict "block" . "fields" $fields) -}}

{{- return $fields -}}

Block types

Add a YAML block file with config (e.g. alert.yml).

layouts/
└── partials/
    └── admin/
        └── blocks/
            └── types/

Content of block type:

{{- $fields := partial "admin/blocks/fields/alert.html" . -}}

{{- $args := dict 
  "label" (i18n "admin.blocks.alert.label")
  "name" "alert"
  "collapsed" false
  "fields" $fields
  -}}

{{ partial "admin/widgets/object.js" $args }}

And add it in enable blocks: see above

Examples

See examples in repository

List of Hugolify blocks

Hugolify blocks