# CostaPy / Template / Create Here is the guide about how to create a template for costapy. What you need to prepare: - template name - static file and directory - raw HTML template - part or component that you want to create ## Create a directory - make a directory with your template name `mkdir learn` - go to a template directory `cd learn` - then `learn` is your template directory ## Routing a static file create `static` directory inside the template directory. create `main.py` inside the template directory and add a static list ```python static = [ { "route" : "/templates/learn/css/", "root" : "./templates/learn/static/css" } ] ``` then you can manage your file on there. For example, put `style.css` on `static/css`. ## Separate the part or component from the raw HTML template create `html` directory inside the template directory. and place your raw `index.html` in here. create `main.py` inside the template directory and set the template parts or components ```python from core import html def main(dir, page): html_template = html.main.get_html("templates/learn/html") html_page = html.main.get_html(dir) return { "index" : html_template [ "index.html" ], "navbar" : html_template [ "navbar.html" ], "footer" : html_template [ "footer.html" ], "container" : html_page [f"{page}.html" ] } ``` adjust and separate the code into a modular file. For example, here I separate `navbar` and `footer` into a modular file. Use python mako template. `index.html` ```python ${title}

${header}

${navbar}
${container}
${footer} ``` `navbar.html` ```python ``` `footer.html` ```python ```