We show that a periodic nanostructure patterned into a polymeric or indium tin oxide (ITO) surface is capable of aligning liquid crystal (LC) molecules. Gratings of different depths were created on thin polymeric or ITO surfaces with submicron and micron periods by superposition of ultraviolet plane waves. The depth of the gratings was varied by changing the fluence of the laser. This method allows to pattern orientations over small areas and does not suffer from the disadvantages of rubbing based alignment methods. LC alignment was tested by forming twisted nematic cells. Anchoring energies were calculated from measurements of the twist angles.