HPV can be prevented by condom use or vaccination.
Condoms can lower the chances of picking up HPV, but are not fully protective as fingers and sex toys involved with sex play may pass on HPV too.
Vaccines can protect against many HPV strains including those most likely to cause anal cancer. However, they are most effective if given before people become sexually active and are exposed to HPV.
The HPV9 (Gardasil) vaccine is recommended for men who have sex with men aged 9-26 and is free for those who are within the age eligibility. Otherwise, the vaccine can be purchased through a sexual health clinic or family physician.
Research supports that even if you already have been exposed to one or more HPV strain, you may still potentially benefit from the vaccine by protection against other strains which you have not yet been exposed to. In people with evidence of prior HPV infection, vaccination can possibly help protect re-acquisition or recurrence of infections leading to warts and other cell changes, including cancer.
Talk to your doctor about vaccination for HPV.