'Latex GitHub links show with symbol

I have a table with several GitHub links. I would like to replace all those links with GitHub symbol. I used fontawesome to render the symbol:

\usepackage{fontawesome}
\faGitSquare

I am not sure how can I replace only the GitHub links with such a symbol? Perhaps modify href? But not sure how to.



Solution 1:[1]

\documentclass{article}

\usepackage{fontawesome5}
\usepackage{hyperref}

\makeatletter
\newcommand{\github}[1]{%
   \href{#1}{\faGithubSquare}%
}
\makeatother

\begin{document}    
\href{https://github.com/samcarter/tikzducks}{\faGitSquare}    
\href{https://github.com/samcarter/tikzducks}{\faGithubSquare}    
\github{https://github.com/samcarter/tikzducks}            
\end{document}

Caveat: this won't work for comment urls that include a #

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alper