Hi @Khushboo Kumari,
Thank you for posting in this community. We sorry to inform you that we can't add indexes to SharePoint site pages. We can only add an index to a list or library column.
You can use Markdown Webpart or Text Editor Webpart to add a Table of Contents to a SharePoint Online communication site.
1.Using Page Anchors to link to a specific location on a SharePoint page.
- Edit the SharePoint Page, then format the text you want to link to as Heading (Heading 1, Heading 2, or Heading 3)
- Republish the Page.
- Next, generate a link by hovering over the header, right-click with your mouse, then choose Copy Link from the pop-up window.
2.Using Markdown Webpart to create a Table of Contents (copy the link you copied above).
3.Using Text Editor Webpart to create a Table of Contents (copy the link you copied above).
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.