Wagtail - Change default HTML-Tag wrapper for StructBlock in StreamField

217 Views Asked by At

I noticed that when my StructBlocks render in the frontend, it's html template is wrapped by a div tag. I would like to change this HTML-Tag for a li tag for example.

Any possibility to do this?

1

There are 1 best solutions below

0
On BEST ANSWER

Per the docs:

In the default rendering, each block of the stream is wrapped in a element (where my_block_name is the block name given in the StreamField definition). If you wish to provide your own HTML markup, you can instead iterate over the field’s value, and invoke {% include_block %} on each block in turn

https://docs.wagtail.org/en/stable/topics/streamfield.html#template-rendering