  We study 't Hooft anomalies of global symmetries in 1+1d lattice Hamiltonian
systems. We consider anomalies in internal and lattice translation symmetries.
We derive a microscopic formula for the "anomaly cocycle" using topological
defects implementing twisted boundary conditions. The anomaly takes value in
the cohomology group $H^3(G,U(1)) \times H^2(G,U(1))$. The first factor
captures the anomaly in the internal symmetry group $G$, and the second factor
corresponds to a generalized Lieb-Schultz-Mattis anomaly involving $G$ and
lattice translation. We present a systematic procedure to gauge internal
symmetries (that may not act on-site) on the lattice. We show that the anomaly
cocycle is the obstruction to gauging the internal symmetry while preserving
the lattice translation symmetry. As an application, we construct anomaly-free
chiral lattice gauge theories. We demonstrate a one-to-one correspondence
between (locality-preserving) symmetry operators and topological defects, which
is essential for the results we prove. We also discuss the generalization to
fermionic theories. Finally, we construct non-invertible lattice translation
symmetries by gauging internal symmetries with a Lieb-Schultz-Mattis anomaly.
