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
2The 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.
Filters
- abs
- append
- at_least
- at_most
- capitalize
- ceil
- compact
- concat
- date
- default
- divided_by
- downcase
- escape
- escape_once
- first
- floor
- join
- last
- lstrip
- map
- minus
- modulo
- newline_to_br
- plus
- prepend
- remove
- remove_first
- replace
- replace_first
- reverse
- round
- rstrip
- size
- slice
- sort
- sort_natural
- split
- strip
- strip_html
- strip_newlines
- times
- truncate
- truncatewords
- uniq
- upcase
- url_decode
- url_encode
- where
- raw
- slugify
- number_format
