Monday, April 17, 2017

Drupal - Creating Anchors in your Articles

Note: This post uses CKEditor in Drupal as the WYSIWYG editor.

The web term is called an "anchor". A place in the web page that marks a section of the page that you can jump to.

When editing the Medical Article Summary, place your cursor at the location you want the anchor. Then click the FLAG icon in the editor (see screenshot).



After clicking the FLAG icon (Anchor), a popup will show asking what you want to call it. Use any name you want with no spaces.



I used the name "anchor1".

Now if I want to automatically jump to this section when I go to view the article, I just append the anchor (with the '#’ symbol).

So what was before: https://example.com/article/test
Now becomes:          https://example.com/article/test#anchor1


This is also how Table of Contents are done on a web page, by having a list of items that you can jump to.


You can have multiple anchors within a web page, but they need to be unique within that web page. In this page, I could not have 2 anchors named "anchor1" or else we don’t know where to jump. However I could have "anchor1" in one article and then "anchor1" in a completely different article.