How to properly program AJAX links?
If you just need to add the classes I believe it can be done like so
$url = Url::fromRoute(
  'entity.node.canonical', 
  ['node' =&gt; $record-&gt;nid], 
  ['#attributes' =&gt; ['class' =&gt; ['btn', 'btn-default', 'use-ajax']]]
);

 $title_link = Link::fromTextAndUrl($record-&gt;title, $url);

At that point $title_link should be able to be rendered in the template as is!
// php
$variables['title_link'] = $title_link;

// twig
{{ title_link }}