modulo

Calculate the integer remainder of dividing the input number by a given divisor.

Syntax

{{ number | modulo: divisor }}

Example

{% assign step = 8 %}{{ step | modulo: 3 }}

Output

2

The modulo filter calculates the remainder after dividing an integer by the specified divisor, ideal for cyclic counters and alternating layouts.

On programmatic landing pages, modulo creates alternating grid styles or zebra-striped pricing tables. For example: {% assign parity = forloop.index | modulo: 2 %}{% if parity == 0 %}class="row-alt"{% endif %}. This visual rhythm breaks up long feature lists, keeping readers engaged across deep comparative tables.

Try this syntax in the editor.