There are many ways to work it out with some being those already mentioned like naming conventions, same occupation as father etc, however, sometimes it is impossible to be 100% sure.
Another way is to look at wills. Don't just look at wills that are for the same last name. Open up a blank search for the town and nearby towns the said person lived in and look at all the wills from the date of the persons death back 100 years. Then skim read all of them for known names. It can be laborious but sometimes worth it.
Doing that kind of search with the wills, you can look for potential legacies left to your relative or their children. This allows you to sometimes find cousins, uncles/aunts, siblings, mother/son/father/daughter-in-laws etc (that may not have the same last name) that mention your known relative and allow you to piece it together.
If only Ancestry or findmypast allowed searching names mentioned within the wills it would be so much easier.
Other methods that can be used depending on the county, timeframe your looking at and what is available are inquisitions, land records, tax lists, quarter sessions, churchwarden records, protestation returns (1642), removal records, etc to name a few. All available at ancestry for Yorkshire or online elsewhere.
Also you cant rely on just using search on ancestry or the like as there are some records that are not indexed. Looking at ancestry for Yorkshire (card catalogue with keyword search for Yorkshire) there are a few records that are not indexed so require looking at images one by one.
Lastly try searching google books or internet archive for the last name of the person and the town. There are many records that are available at these places (even snippets) that can reveal results from books, genealogy societies, etc which are not available on the more popular genealogy sites like ancestry.
The further you get back away from 1800, the more records you need to look at that are not indexed (searchable).