There are a few rules for determining the gender of masculine, feminine and neuter.
But, very often, you have to memorize each word's gender.
Gender of Masculine Nouns
https://www.germanveryeasy.com/masculine-noun-genderFeminine Noun Gender
https://www.germanveryeasy.com/m/feminine-noun-genderGender of Neuter Nouns in German
https://www.germanveryeasy.com/m/neuter-noun-gender
Game: Guess the Gender
https://www.germanveryeasy.com/m/exercise-gender