To add a Toplink in your website header, create a custom module and then follow this:
Method#1 Basic link using layout XML
// app/code/Namespace/Modulename/view/frontend/layout/default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="top.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="whatsapp-link" before="my-account-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">Contact us on Whatsapp</argument>
<argument name="path" xsi:type="string">some-path-url-string</argument>
<argument name="class" xsi:type="string" translate="false">contact-whatsapp</argument>
<argument name="sortOrder" xsi:type="number">100</argument>
<argument name="target" xsi:type="string">_blank</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
By just using this file, you will be able to create a custom top link, and with the added class you can style it in you css/less files.
Method#2 Using Template phtml file Sometimes there are requirements when you need more control over newly added toplinks, or add image or write your own html. For adding a custom toplink using a template, follow this way.
// app/code/Namespace/Modulename/view/frontend/layout/default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="top.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="whatsapp-link" template="Namespace_Modulename::whatsappLink.phtml">
</block>
</referenceBlock>
</body>
</page>
And then add the template phtml file defined in xml above in your code as follow.
// app/code/Namespace/Modulename/view/frontend/templates/whatsappLink.phtml
<li class="link whatsapp-link">
<a href="some-path-url-string" title="Connect via Whatsapp" target="_blank">
<img class="whatsapp-img" src='<?php echo $this->getViewFileUrl('Namespace_Modulename::images/WhatsApp_logo.png'); ?>' alt="Whatsapp Image">
<span class="whatsapp-label">Connect via Whatsapp</span>
</a>
</li>
Using this way, I added my icon with toplink and I can play with it as per requirement.