PyCharm 2026.3 Help

Templates with multiple files

Some programming patterns and frameworks require a set of related files, usually with a very specific structure. For example, a web component can consist of a Python module, an HTML template, a style sheet, and a JavaScript file stored in one folder.

In PyCharm, you can create sets of related files by adding child templates to a file template. When you create a file from such a template, it will also create files from child templates.

Create a template with multiple files

  1. In the Settings dialog (Ctrl+Alt+S) , select Editor | File and Code Templates.

  2. Create the main file template.

    On the Files tab, click the Create Template button and specify the name, file extension, and body of the template.

  3. Select the new template in the list and click The Create Child Template File button on the toolbar. Specify the name, file extension, and body of the child template.

Example: Template for a folder with several files

Suppose you want to create a header folder with the header.py, header.html, header.css, and header.js files in it.

  1. In the Settings dialog (Ctrl+Alt+S) , select Editor | File and Code Templates.

  2. Create the main template for the Python file:

    1. On the Files tab, click the Create Template button (Create Template).

    2. In the Name field, type Component folder. In the Extension field, type py.

    3. In the File name field, type $NAME/$NAME. The part before the slash is the name of the folder, the part after the slash is the name of the file in it.

    4. Optionally, add the template body, for example:

      # Created by ${USER} on ${DATE}
  3. Add a child template for each of the other files:

    1. Select the Component folder template in the list and click the Create Child Template File button (Create Child Template File).

    2. In the File name field, type $NAME/$NAME. In the Extension field, type html.

    3. Repeat these steps to add child templates with the css and js extensions.

  4. Click OK to save the templates.

  5. In the Project tool window, right-click the directory where you want to create the folder and select New | Component folder.

    In the dialog that opens, type header and click OK.

    PyCharm creates the header folder with four files in it.

09 October 2026