Print affiliate link in theme?

How can I print a blogs affiliate link in a theme template?

If affiliate, link to home with affiliate ID, else, link to home.

Thanks