Skip to content

Support .ng template file type as an alternative to .html #67545

@pkurcx

Description

@pkurcx

Which @angular/* package(s) are relevant/related to the feature request?

compiler

Description

Angular templates are currently stored mostly as .html files. In practice, many formatters and tooling ecosystems detect Angular templates using naming conventions such as .component.html.

Since Angular v20 style guidance moved away from strict .component suffix conventions, more projects use no-suffix or simplified file naming. As a result, tools like Prettier, dprint, Biome, and oxfmt often fail to reliably detect Angular template files and apply Angular-aware formatting rules.

This creates inconsistent formatting behavior and forces users into formatter-specific workarounds.

A dedicated Angular template extension (for example .ng) would provide explicit, tool-agnostic identification of template files.

Proposed solution

Introduce support for .ng as a first-class Angular template file extension, alongside .html.

Expected behavior

  • Angular compiler and CLI accept .ng template files for templateUrl.
  • Tooling/documentation formally recognizes .ng as an Angular template extension.
  • Existing .html templates remain fully supported (no breaking change).
  • Migration can be incremental, project-by-project.

Why this helps

  • Removes dependency on filename suffix heuristics (e.g. .component.html).
  • Gives formatter authors one clear signal to detect Angular templates.
  • Aligns with framework-specific template extensions used elsewhere (e.g. .vue, .svelte, .astro).
  • Better reflects that Angular templates are framework templates, not generic HTML documents.

Alternatives considered

  1. Keep .html and require formatter-specific heuristics/workarounds

    • Rejected: duplicates effort across each formatter and remains fragile.
  2. Enforce/revive .component.html naming convention

    • Rejected: conflicts with current naming preferences and does not solve broader tooling ambiguity.
  3. Add formatter plugins/rules per ecosystem only

    • Rejected: partial, inconsistent ecosystem coverage and ongoing maintenance burden.
  4. Add Angular-specific file-level pragma/comments in .html files

    • Rejected: extra boilerplate and still requires every formatter to implement custom parsing behavior.

Formatter issues:

prettier/prettier#18665
g-plane/markup_fmt#209
oxc-project/oxc#17852

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compilergemini-triagedLabel noting that an issue has been triaged by gemini

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions