I would say Head First is simply wrong in this characterization.
Wikipedia defines Template Method as:
In software engineering, the template method pattern is a behavioral design pattern that defines the program skeleton of an algorithm in an operation, deferring some steps to subclasses.
(It references GoF for that.)
And Factory Method is defined as:
In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created.
There is no overlap between the two, except that in C++, inheritance is a key part of both. However, in languages that make a distinction between implementation inheritance (
extends in Java) and interface implementation (
implements in Java), even this commonality doesn't exist, since interface implementation is sufficient for factory method, but not template method. And in C++, pure implementation inheritance (without the interface inheritance, i.e. private inheritance or CRTP) can be used for the former, but not for the latter.
And aside from that? One is a behavioral design pattern, the other a creational pattern. One describes an outline of an operation, with some key parts left out to be filled in by specialized subclasses; the other specifies a very simple contract, leaving the entire implementation to the concrete instances. They are completely distinct.
In my opinion, the line as quoted is simply wrong. Either it is a glaring error in the book, or (less likely) it is out of context and should be interpreted differently.