You can do that in many different ways ![]()
If you have the option Outline enabled in setting it will create a list of all the heading no the right sidebar.
Settings-> Core plugins → Outline
If you want that only on the top of the files so you can use a community plugin TOC (Dynamic Table of Contents), once installed and enabled you only need to add to the top of the file this code:
```toc style: number ```
PS2: With this if you ever need to Export to PDF in Obsidian you will have an automatic index created ![]()