We have performed a systematic study on the crystal structures and electronic properties of two ternary hydrides, YSH 6 and LaSH 6 , under pressure, using the particle swarm optimization method and first-principles calculations. As a result of extensive structure searches, metallic YSH 6 and LaSH 6 are thermodynamically stable between 195-237 and 170-300 GPa, respectively. Interestingly, in YSH 6 eight neighboring hydrogen atoms form octagons, and the octagons in different layers are connected by four sulfur atoms, forming a cagelike structure with a Y atom at the center, while those octagons in the same layer form polyphenylene-like chains via one shared side. In LaSH 6 , however, hydrogen atoms form both curved "H 5 " chains or straight chains when bonded to sulfur atoms. Furthermore, electron-phonon coupling calculations indicate that YSH 6 and LaSH 6 are promising superconductors with estimated T c values of 91 and 35 K at 210 and 300 GPa, respectively. These results provide guidance for future experimental studies and stimulate more exploration on ternary hydrides.