A proven approach is Michael Hartl's (@mhartl) Rails tutorial, which has grossed multiple six figures with the entire content free to read online, plus upgrades for DRM-free PDF, videos and print. That's well more than 10X the average return on technical books.