Skip to content

Commit

Permalink
Merge pull request #177 from toppers/update-GA4
Browse files Browse the repository at this point in the history
Update ga4
  • Loading branch information
mitsut authored May 19, 2024
2 parents d07ff80 + 1e07e8f commit 6ed3567
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,44 @@ name: github pages
on:
push:
branches:
- web
- '**'

jobs:
deploy:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'

- name: Build
run: hugo --minify

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: public
path: ./public

deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/web'
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: public
path: ./public

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_dir: ./public
4 changes: 3 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ title = "箱庭"
theme = "kube"
description = "IoT/クラウドロボティクス時代の仮想シミュレーション環境"
Paginate = 4
GoogleAnalytics = "G-57DLKTNNK8"

DefaultContentLanguage = "ja"

[Services.GoogleAnalytics]
ID = "G-57DLKTNNK8"

[languages]
[languages.ja]
languageName = "JP"
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/analytics.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{ if not hugo.IsServer }}
{{ with .Site.GoogleAnalytics }}
{{ with .Site.Config.Services.GoogleAnalytics.ID }}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.GoogleAnalytics }}"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ .Site.GoogleAnalytics }}');
gtag('config', '{{ . }}');
</script>
{{ end }}
{{ end }}

0 comments on commit 6ed3567

Please sign in to comment.