Please consider this tutorialif your are willing to use CHARMM force field just register on the above mentioned cgenff website then upload yoir ligand molecle, otherwise, you could use GROMOS force field and rely on PRODRG server which is a way easier to generate a topology file for ligands.
The CGenFF server provides a stream file (CHARMM topology) for your ligand. If you want to convert it to GROMACS format, use the cgenff_charmm2gmx.py script that is provided by the MacKerell lab: