pydata / pydata-sphinx-theme

A clean, three-column Sphinx theme with Bootstrap for the PyData community
https://pydata-sphinx-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
604 stars 314 forks source link

Google analytics does not work; jupyterbook markdown #2011

Open CassStevenson opened 3 hours ago

CassStevenson commented 3 hours ago

Hi there,

I recently moved to pydata-sphinx-theme due to its flexibility for customization. I'm deploying a jupyterbook to GitHub pages; written entirely in markdown with jupytext/myst. I have successfully added google analytics ID using the default jupyterbook theme, but as soon as I add pydata-sphinx-theme to my config.yml file, pydata-sphinx-theme works but google analytics no longer works (left same as how it was in normal jupyterbook theme). Is this because my config file is .yml and not config.py? Any other ideas as to how I can fix this?

I'm not sure if this help, but the repo can be found here: https://github.com/AB-RCSC/rc-decision-support-tool_concept-library

drammock commented 3 hours ago

I don't have much experience deploying JupyterBooks, but looking at https://jupyterbook.org/en/stable/advanced/sphinx.html, they say:

Warning: Adding your own Sphinx configuration and extensions may cause Jupyter Book to behave unpredictably. Use at your own risk!

and in particular, this section of that page says:

...you should consult the PyData theme documentation for information about how to configure it.

The relevant documentation is here: https://pydata-sphinx-theme.readthedocs.io/en/latest/user_guide/analytics.html#google-analytics

Your config file doesn't have the analytics key in html_theme_options:

https://github.com/AB-RCSC/rc-decision-support-tool_concept-library/blob/14c0777d74e207cebe60d9cbd322597fa9c17d60/_config.yml#L163

(something correct-looking is commented out higher up in the file, though with a different GA-ID: https://github.com/AB-RCSC/rc-decision-support-tool_concept-library/blob/14c0777d74e207cebe60d9cbd322597fa9c17d60/_config.yml#L125-L127)

TL;DR: in the repo's YAML config, it's not configured right.