Requirement: Add modern page anchor link in SharePoint Online.
How to Create Bookmarks on a modern page in SharePoint Online?
Page Anchors are links to another section on the same page. E.g. Jump to section, Table of contents, etc. on long pages. You can create the page anchor by using any of the heading styles in the Text web part.
Step 1: Create a Page, Add content to it and format the Sub-headings with Heading styles, such as H1, H2 or H3. Save and Publish the page.
Step 2: Open the same page in a new tab, edit the page, and add text for links to these sections. E.g. “Table of Contents” in the top section of the page.
Step 3: On the published page, Just mouse over the subheadings that are formatted with heading styles. You’ll find a link next to those subheadings. Just copy the link from the published page. (These links don’t appear on pages in edit mode!)
Step 4: Now, Select the text you want to link on the page in edit mode, click on the “Hyperlink” button in the toolbar.
Step 5: Enter the link for the selected text you copied from the published page. Typically, it would look like: https://yourdomain.sharepoint.com/sitepages/page.aspx#section
That’s all! Now, clicking the links under “Table of Contents”, will take users to the relevant sections of the page.