How do I add an attribute in an anchor tag?
You can do it using hook_link_alter

/**
 * Implements hook_link_alter().
 */
function mymodule_link_alter(&amp;$variables) {

    $variables['options']['attributes'] = array('data-anchor' =&gt; 'arial');

}