Every so often one of those Internet lists of things writers should never do gets forwarded around -- usually lists of cliches for particular genres. They mostly seem to be written as humor aimed at those familiar with the genre tropes, but are often presented, or at least forwarded, with the idea that if you do any of those things in your book, your book will be cliched, derivative and awful and is guaranteed not to sell. The last time I looked at one of those lists for the fantasy genre, I realized that most of my favorite books would never have been written or published if the authors or publishers had taken a list like that seriously. The fantasy writer Diana Wynne Jones wrote a humorous book on the cliches that come up in fantasy fiction (The Tough Guide to Fantasyland) and then wrote a whole series in which she proceeded to cleverly use all those cliches. There's a difference between a trope and a cliche -- my personal definition is that the trope is used as a framework upon which something original can be built, while the cliche stops at the superficial. How do you avoid doing it the wrong way and having a book full of cliches?
1) Know your genre.
The best way to avoid cliches is to know what they are and to see how the tropes have been used. You should have some working familiarity with what's selling in your genre today, but you should also look at the classics of the genre over the years and the roots of the genre. If you write mystery, you should probably have read some Agatha Christie, Dorothy L. Sayers, Raymond Chandler and the like, as well as going back to Wilkie Collins, Arthur Conan Doyle and Edgar Allen Poe. For fantasy, you need to have read Tolkien and Lewis, and it's probably a good idea to have read some folklore and mythology. Doing the background reading will help you recognize the common tropes and cliches that pop up in today's books. It will also help you know when a commonly believed cliche isn't really one.
For instance, one of those "fantasy cliches you should never use" list mentioned the farmboy who turns out to be the rightful king. I've read a ton of fantasy, and I can only think of one book off the top of my head where that happened -- Lloyd Alexander's The High King, in which the assistant pig keeper becomes the king. Maybe this trope was overused in bad fantasy books that haven't stood the test of time enough for me to have seen them, but I don't think it's common enough that it falls into the "must avoid" zone. It was fairly common in fairy tales for the third son of a farmer or woodcutter to win the hand of the princess and end up becoming the king, but he did that through feats of skill or strength, usually magically aided because of some good deed he'd done. It's far more common in fantasy for some unlikely person -- the farmboy, baker's assistant, neglected orphan -- to find out he has some kind of magical powers.
2) Think about the cliche or trope
These things are popular enough to be overused for a reason (and not just writer laziness). Going back to the unlikely person becoming powerful trope, that really makes for a more interesting story than a likely person becoming powerful. There's not much drama or contrast in the son of a king becoming a king or the son of a wizard who grew up surrounded by wizard stuff becoming a wizard. Then there's the wish fulfillment angle of the reader. Most of us aren't children of royalty or wizards, so for us to achieve great power it would have to be an "unlikely person" story. We can put ourselves in the position of a character and vicariously enjoy finding out we're special. Going to another genre, I was once part of a conversation in which a group of romance novelists were griping to an editor about the marriage of convenience cliche and how maybe it was outdated. The editor said to think of what it represented -- legalized sex with a stranger. Once you know and understand how the trope works and why it's popular, you may be able to find ways to provide the same appeal in a different way.
3) Do your research
A lot of the cliches get propagated through writers using other novels as their research material. Your work will come across as more original if you get beyond the commonly accepted facts to what's really true. If you're writing quasi-medieval fantasy, do some good research into the real medieval period. If you're writing mystery, research true crime and police procedure. You may find a telling detail that helps you subvert or elevate the cliche and that will make your work come across as a lot more original.
4) Think it through and flesh it out
You'll have a cliche if you just stop at that usual plot trope. Put more thought into it and readers may not even consciously notice the trope because they'll be too busy reading about your three-dimensional characters. Take the example of the farmboy who's really the rightful king (whether or not that's really a cliche). How did the rightful heir come to be living on a farm? Say the king saw a coup coming and sent his newborn son off with his most trusted soldier and a nursemaid, and they hide out on a remote farm. Did the soldier grow up on a farm, so he knows what he's doing, or has he always been a soldier? What does he think about farming? What's his relationship to the nursemaid? Does the prince know who he is or does he think they're his parents? Does the soldier teach him soldier stuff, or is he so paranoid that he doesn't dare give even that much hint about his identity? What does the farmboy prince think about being on a farm? What are his ambitions? What does he think when he learns who he is? Do his ambitions change? How does his farming background affect the way he goes after his throne? You could probably get a dozen different stories based on this trope depending on the answers you give these questions. The key is to not stop at "farmboy who's really a prince" but to make him a real character with real goals and motivations who is affected by his environment.