Mako Templating Library
Mako is a hyperfast and lightweight templating language for Python, designed to be both powerful and easy to use. The current version is 1.3.10, released on March 28, 2026. Mako follows a regular release cadence, with updates addressing bugs and improvements.
Warnings
- breaking Mako now requires Python >= 3.7, removing support for Python 2 and Python 3.6.
- deprecated The use of 'import="*"' in <%namespace> is known to decrease performance and will be fixed in a future release.
Install
-
pip install mako
Imports
- Template
from mako.template import Template
- TemplateLookup
from mako.lookup import TemplateLookup
Quickstart
from mako.template import Template
from mako.lookup import TemplateLookup
# Set up template lookup
mylookup = TemplateLookup(directories=['/path/to/templates'])
# Load a template
mytemplate = mylookup.get_template('mytemplate.html')
# Render the template with variables
output = mytemplate.render(variable1='value1', variable2='value2')
print(output)