ATX headings
# through ###### . The space after the hashes is required in CommonMark: #Title stays a paragraph (and on GitHub, a hashtag-like link).
Setext headings
Underline a line with === for H1 or --- for H2. Only two levels, and --- under a paragraph can be mistaken for a horizontal rule, so ATX is usually clearer.
Structure
Use one H1 as the document title and nest in order (H2, then H3). Screen-reader users navigate by headings, and markdownlint rules MD001 and MD025 flag skipped levels and multiple H1s.
Anchors
Renderers create an id from the heading text, so you can link to #heading-text. See links. The editor here can insert a linked table of contents from your headings.
Blank lines
Put a blank line before and after headings. Some renderers require it, and it keeps the source readable.