diff --git a/.gitignore b/.gitignore
index 0edc644f0da08a8b5735673bf97ca6dc7439e09c..0d34b4b5dac373bf45b20c927fc21c410423241d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@ ChangeLog
 \#*
 .\#*
 .php_cs.cache
+.php_cs_template.cache
 TAGS
 *~
 /downloads
diff --git a/build.xml b/build.xml
index 1a342d18e15a065073d41a0576faf5fd19bc93be..5935754003405079a51ef6a79910b068cb0f654f 100644
--- a/build.xml
+++ b/build.xml
@@ -103,9 +103,11 @@
   <!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) -->
   <target name="php-cs-fixer">
     <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php_cs --verbose" passthru="true" escape="false" />
+    <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind_templates.php_cs --verbose" passthru="true" escape="false" />
   </target>
   <target name="php-cs-fixer-dryrun">
     <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php_cs --dry-run --verbose --diff" passthru="true" escape="false" checkreturn="true" />
+    <exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind_templates.php_cs --dry-run --verbose --diff" passthru="true" escape="false" checkreturn="true" />
   </target>
 
   <!-- ESLint -->
diff --git a/tests/vufind_templates.php_cs b/tests/vufind_templates.php_cs
new file mode 100644
index 0000000000000000000000000000000000000000..8cb5bd0b3e9defbecc2a34de741992c231eafe69
--- /dev/null
+++ b/tests/vufind_templates.php_cs
@@ -0,0 +1,68 @@
+<?php
+
+$finder = PhpCsFixer\Finder::create()->in(__DIR__ . '/../themes')
+    ->name('*.phtml');
+
+$rules = [
+    'align_multiline_comment' => true,
+    'array_syntax' => ['syntax' => 'short'],
+    'binary_operator_spaces' => [
+        'default' => 'single_space',
+    ],
+    'blank_line_after_namespace' => true,
+    //'braces' => true, // disabled because we don't want to create inconsistent indentation, but useful to normalize control structure spacing
+    'cast_spaces' => ['space' => 'none'],
+    'concat_space' => ['spacing' => 'one'],
+    'elseif' => true,
+    'encoding' => true,
+    //'full_opening_tag' => true, // using full tags is best practice, but it detracts from readability; we should discuss
+    'function_declaration' => true,
+    'function_typehint_space' => true,
+    'indentation_type' => true,
+    'line_ending' => true,
+    'lowercase_cast' => true,
+    'lowercase_constants' => true,
+    'lowercase_keywords' => true,
+    'magic_constant_casing' => true,
+    'method_argument_space' => true,
+    'method_separation' => true,
+    'native_function_casing' => true,
+    'no_blank_lines_after_class_opening' => true,
+    'no_blank_lines_after_phpdoc' => true,
+    'no_blank_lines_before_namespace' => true,
+    'no_empty_comment' => true,
+    'no_empty_phpdoc' => true,
+    'no_empty_statement' => true,
+    'no_extra_consecutive_blank_lines' => true,
+    'no_leading_import_slash' => true,
+    'no_leading_namespace_whitespace' => true,
+    'no_mixed_echo_print' => true,
+    'no_singleline_whitespace_before_semicolons' => true,
+    'no_spaces_after_function_name' => true,
+    'no_spaces_around_offset' => true,
+    'no_spaces_inside_parenthesis' => true,
+    'no_trailing_whitespace' => true,
+    'no_unneeded_control_parentheses' => true,
+    'no_unneeded_curly_braces' => true,
+    'no_unused_imports' => true,
+    'no_useless_return' => true,
+    'no_whitespace_before_comma_in_array' => true,
+    'no_whitespace_in_blank_line' => true,
+    'ordered_imports' => true,
+    'phpdoc_no_access' => true,
+    'single_blank_line_at_eof' => true,
+    'single_class_element_per_statement' => true,
+    'single_import_per_statement' => true,
+    'single_line_after_imports' => true,
+    'short_scalar_cast' => true,
+    'standardize_not_equals' => true,
+    'switch_case_semicolon_to_colon' => true,
+    'switch_case_space' => true,
+    //'ternary_operator_spaces' => true, // disabled due to bug in php-cs-fixer 2.7.1
+    'visibility_required' => true,
+];
+
+return PhpCsFixer\Config::create()
+    ->setCacheFile(__DIR__ . '/../.php_cs_template.cache')
+    ->setRules($rules)
+    ->setFinder($finder);