On July 25, 2018, Hernández pitched in a game for the first time in his career, entering in the 16th inning against the Philadelphia Phillies and picking up the loss after walking two batters and giving up a three-run walk-off home run. He is the first position player since Babe Ruth to play in the infield, outfield and give up 3 runs or more in the same game. He is also the first position player ever to give up a walk-off home run. For the season, he batted .256/.336/.470, hitting a career high 21 home runs and 52 RBIs. In the postseason, he was two for 12 in the NLDS against the Atlanta Braves, one for 14 in the NLCS against the Milwaukee Brewers and two for 15 in the 2018 World Series against the Boston Red Sox, with one home run.