# How does one compute the posterior in a two-stage Bayesian model?

Given a random variable $$X$$ depending on a parameter $$\theta$$ which itself depends on a parameter $$\psi$$, how do I compute $$p(\theta|X,\psi)$$?

A website I have found$$^1$$ claims that $$p(\theta|X,\psi)=\frac{p(\theta|\psi)\cdot p(X|\theta)}{\int_{\Theta}p(\theta| \psi)\cdot p(X| \theta)d\theta}$$ but I haven't been able to derive this so far. The only way of doing something remotely useful with the LHS that I have found is to simply plug in the definition of conditional probability. I would also guess that the integral is a result of applying the law of total probability but I'm not sure how exactly to continue from this.

$$^1$$:https://people.stat.sc.edu/hitchcock/stat535slidesday24.pdf

This is a one-stage Bayesian model, since the hyperparameter $$\psi$$ is fixed, rather than being another random variable. Consider the difference between $$\theta \sim \mathcal N(0,1)$$ $$\theta \sim \mathcal N(\psi_1,\psi_2)\qquad \psi_1=0\,,\psi_2=1$$ and $$\theta|\psi_1=0\,,\psi_2=1 \sim \mathcal N(0,1)$$ There is none! The conditional bar "|" is not used in a probabilistic sense there.
This means that, if $$X|\theta\sim f(x|\theta)\qquad \theta|\psi\sim p(\theta|\psi)$$ then $$\theta|X=x,\psi \sim p(\theta|x,\psi) \propto f(x|\theta) p(\theta|\psi)$$
If $$X$$ depending on a parameter $$θ$$ which itself depends on a parameter $$ψ$$ we should better write this as $$p(X;\theta, \psi)$$, but it should not be wrong to use $$|$$ either just if we mention the right thing.
Because there is no indication $$\theta$$ is random variable.
But Bayes rule should still work $$p(\theta|X,\psi) = \frac{p(X|\theta, \psi)p(\theta, \psi)}{p(X)}$$