Make sure your Hexo and Next theme are up to date.
Step 1:
open the {HEXO_ROOT}\themes\next\_config.yml
file and find the following code:
1 | custom_file_path: |
remove the # from the “#head: source/_data/head.swig” line.
Step 2:
create a file {HEXO_ROOT}\source\_data\head.swig
and put the GA code in this file:
1 | <!-- Global site tag (gtag.js) - Google Analytics --> |
Step 3:
rebuild your site
1 | hexo clean |