# MD041 - First Line Should Be a Top-Level Heading

## Description

This rule ensures that the first content line in a file is a top-level (h1) heading. Starting each document  
with a top-level heading provides a clear title and improves document structure and navigation.

By default, this rule checks for a level 1 heading (# Heading), but it can be configured to check for  
a different heading level.

<!-- markdownlint-disable -->
## Examples

### Valid

```markdown
# Document Title

This is a paragraph in a document with a proper title.
```

### Invalid

```markdown
This document doesn't start with a heading.

Some more content here.

## This is a heading, but not a top-level one
```

### Fixed

```markdown
# Document Title

This document doesn't start with a heading.

Some more content here.

## This is a heading, but not a top-level one
```
<!-- markdownlint-enable -->

## Configuration

This rule has the following configuration options:

- `level`: The heading level to require at the beginning of the document. Default is `1`.
- `front*matter*title`: The name of the front matter title field. Default is `title`.

## Special Cases

- This rule does not apply if the document is empty
- If `front*matter*title` is set and the document has front matter with a title, the rule is satisfied
- The rule ignores YAML, TOML, or other front matter at the beginning of the document
- Comments at the beginning of the document are also ignored

## Related Rules

- [MD001 - Heading increment](md001.md): Ensures heading levels increment by one level at a time
- [MD003 - Heading style](md003.md): Ensures consistent heading style
- [MD025 - Single title/h1](md025.md): Ensures there's only one top-level heading
