↑ ↓ select, Enter open, Esc close

Extract the H1 headings of a page

Adjust the values, the command updates live
user@server
curl -s https://example.com/ | tr '\n' ' ' | grep -oiP '<h1[^>]*>.*?</h1>' | sed -E 's/<[^>]+>//g; s/^\s+|\s+$//g'

Finds all <h1> elements and strips the tags inside them, leaving only the text. One clear main heading per page helps users and search engines understand it. Themes and page builders sometimes produce several H1s or none at all, for example when the logo is marked up as an H1.

Note: Using -c instead of -o with grep and dropping sed only checks whether an H1 exists at all.

Also searched as

  • check h1 tag of a page
  • multiple h1 on one page
  • extract main heading from html
  • page missing h1

Related one-liners

All in SEO checks

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.