Entanglement entropy, or von Neumann entropy, quantifies the amount of uncertainty of a quantum state. For quantum fields in curved space, entanglement entropy of the quantum field theory degrees of freedom is well-defined for a fixed background geometry. In this paper, we propose a generalization of the quantum field theory entanglement entropy by including dynamical gravity. The generalized quantity named effective entropy, and its Renyi entropy generalizations, are defined by analytic continuation of a replica calculation. The replicated theory is defined as a gravitational path integral with multiple copies of the original boundary conditions, with a co-dimension-2 brane at the boundary of region we are studying. We discuss different approaches to define the region in a gauge invariant way, and show that the effective entropy satisfies the quantum extremal surface formula. When the quantum fields carry a significant amount of entanglement, the quantum extremal surface can have a topology transition, after which an entanglement island region appears. Our result generalizes the Hubeny-Rangamani-Takayanagi formula of holographic entropy (with quantum corrections) to general geometries without asymptotic AdS boundary, and provides a more solid framework for addressing problems such as the Page curve of evaporating black holes in asymptotic flat spacetime. We apply the formula to two example systems, a closed two-dimensional universe and a four-dimensional maximally extended Schwarzchild black hole. We discuss the analog of the effective entropy in random tensor network models, which provides more concrete understanding of quantum information properties in general dynamical geometries. We show that, in absence of a large boundary like in AdS space case, it is essential to introduce ancilla that couples to the original system, in order for correctly characterizing quantum states and correlation functions in the random tensor network. Using the superdensity operator formalism, we study the system with ancilla and show how quantum information in the entanglement island can be reconstructed in a state-dependent and observer-dependent map. We study the closed universe (without spatial boundary) case and discuss how it is related to open universe.