{"id":25118,"date":"2020-07-15T18:01:41","date_gmt":"2020-07-15T22:01:41","guid":{"rendered":"https:\/\/www.boldgrid.com\/support\/?p=25118"},"modified":"2021-07-13T12:09:39","modified_gmt":"2021-07-13T16:09:39","slug":"how-to-add-anchor-links-in-wordpress-step-by-step-tutorial","status":"publish","type":"post","link":"https:\/\/www.boldgrid.com\/support\/wordpress-tutorials\/how-to-add-anchor-links-in-wordpress-step-by-step-tutorial\/","title":{"rendered":"How to Add Anchor Links in WordPress &#8211; Step by Step Tutorial"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><div class=\"video-responsive\">\n<p><iframe loading=\"lazy\" title=\"How to Link to Sections of One Page (Anchor Links)\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/0qV2-G-kEo4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<\/div>\n<h2 id=\"what-is-an-anchor\">What is an &ldquo;Anchor?&rdquo;<\/h2>\n<figure id=\"attachment_25121\" aria-describedby=\"caption-attachment-25121\" style=\"width: 223px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/information-management-proposal.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-25121\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/information-management-proposal-223x300.gif\" alt=\"Information Management: A Proposal by Tim Berners-Lee\" width=\"223\" height=\"300\"><\/a><figcaption id=\"caption-attachment-25121\" class=\"wp-caption-text\">Tim Berners-Lee&rsquo;s original proposal that became the World Wide Web, included the concept of &ldquo;Linked Information.&rdquo; <a href=\"http:\/\/info.cern.ch\/Proposal.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Source<\/a><\/figcaption><\/figure>\n<p>The phrase &ldquo;Anchor Links&rdquo; in the modern web usually refers to making a link to a specific section of a page, but this isn&rsquo;t entirely accurate. Technically, all links are anchors&mdash; the &lt;a&gt; HTML element that creates a link actually originally stood for the word &ldquo;anchor.&rdquo;<\/p>\n<blockquote><p>When Tim Berners-Lee first conceived of the web, he envisioned links would be like a ship&rsquo;s anchor for a floating piece of information, keeping it moored to the right location instead of drifting in the cloud.<\/p><\/blockquote>\n<p>Links are more than just a way to move from one web page to another, or even for moving from one part of a page to another part. They are vital for SEO because they inform search engines which pieces of information are related to others. This is why the <strong>&ldquo;Anchor Text&rdquo;<\/strong> you use for links is such a strong factor in your WordPress website&rsquo;s SEO rankings.<\/p>\n<p>This tutorial focuses on <strong>creating anchor links in WordPress<\/strong> so you can link to different sections of a page<strong>.<\/strong> There are two main parts required&mdash; creating ID&rsquo;s for your anchor links to target, and then creating a link with the anchor in it.<\/p>\n<h2 id=\"creating-anchor-ids\">Creating Anchor ID&rsquo;s<\/h2>\n<p>The first step to creating anchor links in WordPress is to label the sections of the page you&rsquo;ll be linking to. You can link to any element, but most commonly, you&rsquo;ll be linking to headings. There are a few things you&rsquo;ll need to know about HTML ID&rsquo;s.<\/p>\n<p>HTML ID&rsquo;s should be <strong>unique<\/strong> on each page. If you use the same ID on two elements on a page, all anchor links will go to the first one that occurs from the top of the page.<\/p>\n<p>ID&rsquo;s also <strong>cannot contain spaces<\/strong>. Commonly, hyphens or underscores will be used in place of spaces.<\/p>\n<p>And finally, ID&rsquo;s should be <strong>semantically relevant<\/strong> to the element they belong to. This is a fancy way of saying that the name you give to an element should describe the purpose of the element.<\/p>\n<p>This article will show you how to add an ID to a heading in three WordPress page editors&mdash; the WordPress &ldquo;Gutenberg&rdquo; Editor, the Classic Editor, and the BoldGrid Post and Page Builder.<\/p>\n<h3 id=\"how-to-add-an-anchor-id-using-the-wordpress-gutenberg-editor\">How to add an Anchor ID using The WordPress &ldquo;Gutenberg&rdquo; Editor<\/h3>\n<p>The WordPress Editor makes adding an ID to a heading very easy. While you&rsquo;re editing a Heading Block, click the arrow to open the <strong>Block &gt; Advanced<\/strong> section in the right-hand settings pane. If you don&rsquo;t see the settings pane, click on the cog icon (&nbsp;&nbsp;), or use the shortcut <strong>Ctrl-Shift-Comma<\/strong>.<\/p>\n<p>From here, you&rsquo;ll see the option to add an <strong>HTML anchor<\/strong>.<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/anchor-id-in-gutenberg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-25142\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/anchor-id-in-gutenberg-1024x744.png\" alt=\"HTML Anchor setting in Gutenberg\" width=\"1024\" height=\"744\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/anchor-id-in-gutenberg-1024x744.png 1024w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/anchor-id-in-gutenberg-300x218.png 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/anchor-id-in-gutenberg-768x558.png 768w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/anchor-id-in-gutenberg.png 1038w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h3 id=\"how-to-add-an-anchor-id-using-the-classic-editor\">How to add an Anchor ID using the Classic Editor<\/h3>\n<p>Adding an ID in the Classic Editor, also known as TinyMCE, is a little more difficult. It involves using the HTML Text Editor, which can be intimidating to newer WordPress users. This is especially true for long, complex sets of content, because there are no visual indicators of which elements are headings.<\/p>\n<p>Here&rsquo;s a trick you can use to easily find the right HTML element in the text editor. Simply highlight the heading before you switch editors, and it will stay highlighted in the text editor.<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/switch-to-text-editor.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25153\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/switch-to-text-editor.gif\" alt=\"Animation showing highlighting an element, then switching to the text editor\" width=\"1034\" height=\"799\"><\/a><\/p>\n<p>Once you&rsquo;ve located the right element, put your cursor inside the &lt; and &gt; carets of the heading element, and add <strong>id=&rdquo;this-ID&rdquo;<\/strong> to the element. Replace this-ID with your own anchor link ID.<\/p>\n<h3 id=\"how-to-add-an-anchor-id-using-the-boldgrid-post-and-page-builder\">How to add an Anchor ID using the BoldGrid Post and Page Builder<\/h3>\n<p>Using the Post and <a href=\"https:\/\/www.boldgrid.com\/wordpress-page-builder-by-boldgrid\/\">Page Builder WordPress Plugin<\/a> makes adding an ID to an element very easy. This is the process outlined in the video at the top of the article.<\/p>\n<p>While you&rsquo;re editing your page, hover your mouse over the heading that you&rsquo;d like to link, and click on the orange <strong>Edit Content<\/strong> context menu, and then click on <strong>Advanced Control<\/strong>.<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/advanced-control-ppb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25180\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/advanced-control-ppb.png\" alt=\"The Advanced Control menu\" width=\"648\" height=\"325\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/advanced-control-ppb.png 648w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/advanced-control-ppb-300x150.png 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>In the Advanced Control menu, the bottom item is the Custom Classes and CSS ID section. Enter your ID into the <strong>CSS ID<\/strong> field.<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/adding-ID-ppb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25181\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/adding-ID-ppb.png\" alt=\"Adding an ID in the Post and Page Builder\" width=\"913\" height=\"671\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/adding-ID-ppb.png 913w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/adding-ID-ppb-300x220.png 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/adding-ID-ppb-768x564.png 768w\" sizes=\"auto, (max-width: 913px) 100vw, 913px\" \/><\/a><\/p>\n<h2 id=\"creating-wordpress-anchors-links\">Creating WordPress Anchors Links<\/h2>\n<p>Now that you&rsquo;ve got your ID&rsquo;s added to the right elements, it&rsquo;s time to create links to go to those ID&rsquo;s. You do this by adding the # (Pound, Hashtag, Number sign, Octothorpe) symbol to your link, followed by the ID. If you&rsquo;re linking to a section of the same page, you only need to use the #this-ID as the link&rsquo;s reference rather than the full URL.<\/p>\n<h3 id=\"linking-to-an-anchor-with-a-text-link\">Linking to an Anchor with a text link<\/h3>\n<p>Regardless of which editor you&rsquo;re using, making text on your page link to an anchor is much the same. Highlight the text that you want to make into a link, and click the &ldquo;Chain&rdquo; icon ( ), or use the shortcut <strong>Ctrl-k<\/strong>. Then, enter the the ID name with the # symbol before it.<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/link-to-anchor-on-same-page.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25192\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/link-to-anchor-on-same-page.png\" alt=\"Creating a link to an anchor on the same page\" width=\"767\" height=\"162\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/link-to-anchor-on-same-page.png 767w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/link-to-anchor-on-same-page-300x63.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/a><\/p>\n<h3 id=\"wordpress-anchor-links-in-a-menu\">WordPress Anchor Links in a Menu<\/h3>\n<p>Since Menus appear on multiple pages of your website, you&rsquo;ll need to use the full URL of the page, followed by the #this-ID label. That also means you&rsquo;ll need to use the <strong>Custom Link<\/strong> menu item type.<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/custom-link-menu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25195\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/custom-link-menu.png\" alt=\"\" width=\"809\" height=\"545\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/custom-link-menu.png 809w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/custom-link-menu-300x202.png 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/custom-link-menu-768x517.png 768w\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" \/><\/a><\/p>\n<h2 id=\"anchor-links-in-wordpress-and-sticky-headers\">Anchor Links in WordPress and Sticky Headers<\/h2>\n<p>Now that you have created your anchor links, you might want to take some additional steps to provide a better experience for your website&rsquo;s visitors. By default, anchor links abruptly send the visitor to the section of the page. This can be a jarring experience and leave your visitor feeling disoriented, because they won&rsquo;t have any visual queue which part of the page they&rsquo;re now seeing.<\/p>\n<p>Additionally, if your theme features a &ldquo;sticky header,&rdquo; that remains visible on your page even if you scroll down, you&rsquo;ll find that your anchors appear &ldquo;below&rdquo; the header. That&rsquo;s because by default, the browser puts the anchor right at the very top of the page.<\/p>\n<p>One of the best parts about using WordPress is that there are so many free ways to improve your website in the WordPress Plugin Repository. The plugin <a href=\"https:\/\/wordpress.org\/plugins\/easy-smooth-scroll-links\/\" target=\"_blank\" rel=\"noopener noreferrer\">Easy Smooth Scroll Links<\/a> is free, doesn&rsquo;t have any upsells, has largely good reviews, and takes care of both the user experience as well as lets you specify an <strong>offset<\/strong>. An offset will let you deal with a sticky header.<\/p>\n<h3 id=\"how-to-find-your-sticky-header-offset\">How to find your Sticky Header Offset<\/h3>\n<p>The offset is a value, in pixels, of how much to move your anchors down so that they don&rsquo;t go into your sticky header. In order to find out how many pixels tall your header is, visit your website in Firefox or Chrome. Right click on your header, and click <strong>Inspect<\/strong> in Chrome, or <strong>Inspect Element<\/strong> in Firefox. Then, hovering over it, you&rsquo;ll see the element&rsquo;s dimensions just below it.<br>\n<a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/inspect-header.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-25199\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/inspect-header.png\" alt=\"Clicking Inspect, and seeing the element's dimensions\" width=\"517\" height=\"628\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/inspect-header.png 517w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2020\/07\/inspect-header-247x300.png 247w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/a><\/p>\n<p>The second number is the height, in this example 110 pixels. Now you can use that value to determine your offset. You may want to add 5-20 pixels to put a little space between your Anchor and your header.<\/p>\n<p class=\"h4\">Congratulations! Now you know how to create Anchor Links in WordPress!<\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>What is an &ldquo;Anchor?&rdquo; The phrase &ldquo;Anchor Links&rdquo; in the modern web usually refers to making a link to a specific section of a page, but this isn&rsquo;t entirely accurate. Technically, all links are anchors&mdash; the &lt;a&gt; HTML element that creates a link actually originally stood for the word &ldquo;anchor.&rdquo; When Tim Berners-Lee first conceived [&hellip;]<\/p>\n","protected":false},"author":1294,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"bgseo_title":"How to Add Anchor Links in WordPress - Step by Step Tutorial","bgseo_description":"Learn how to create anchor links in WordPress. The \"Anchor Text\" you use for links is a strong factor in your WordPress website SEO rankings.","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[151],"tags":[],"class_list":["post-25118","post","type-post","status-publish","format-standard","hentry","category-wordpress-tutorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/25118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/users\/1294"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/comments?post=25118"}],"version-history":[{"count":51,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/25118\/revisions"}],"predecessor-version":[{"id":40471,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/25118\/revisions\/40471"}],"wp:attachment":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/media?parent=25118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/categories?post=25118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/tags?post=25118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}