Writing Topology file for Ligand for Gromacs
First off, you should not be manually writing topology files whenever you can avoid it - it's far too prone to making silly errors. That's why there are so many programs out there that attempt to automate the process.

If however, you just want to understand HOW the topology file is structured, I recommend reading the GROMACS manual (chapter 5). These tutorials also do a good job of describing some of the key aspects of the topology files.