How to Write a Metaphor?

You can write a metaphor by comparing one thing to another, using the word ‘like.’ An example would be the phrase ‘I was drawn to the candy like a moth to a flame.’