Skip to content

Commit

Permalink
Ensure analytics is enabled in production only
Browse files Browse the repository at this point in the history
Signed-off-by: Patrice Chalin <[email protected]>
  • Loading branch information
chalin committed Jul 22, 2022
1 parent 025c9d7 commit 8db8904
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ resources/
# Link checker assets
bin/
tmp/
.hugo_build.lock
package-lock.json
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

DEPLOY_PRIME_URL?=/
HUGO?=npx hugo

clean:
rm -rf public resources
rm -rf public/* resources

serve:
hugo server \
--buildDrafts \
--buildFuture \
--disableFastRender
$(HUGO) serve -DEF --disableFastRender

build:
$(HUGO) --cleanDestinationDir -e dev -DEF

production-build:
hugo \
--minify
$(HUGO) --cleanDestinationDir
# --minify

preview-build:
hugo \
--baseURL $(DEPLOY_PRIME_URL) \
--buildDrafts \
--buildFuture
$(HUGO) --cleanDestinationDir -e dev -DEF --baseURL $(DEPLOY_PRIME_URL)

install-link-checker:
curl https://raw.githubusercontent.com/wjdp/htmltest/master/godownloader.sh | bash
Expand Down
6 changes: 3 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
publish = "public"
command = "make production-build"

[build.environment]
HUGO_VERSION = "0.65.3"

[context.deploy-preview]
command = "make preview-build"

[context.branch-deploy]
command = "make preview-build"

[context.production.environment]
HUGO_ENV = "production"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"private": true,
"devDependencies": {
"bulma": "^0.7.1"
"bulma": "^0.7.1",
"hugo-extended": "0.65.3"
}
}
5 changes: 4 additions & 1 deletion themes/containerd/layouts/partials/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ $isProduction := eq hugo.Environment "production" -}}
{{ if $isProduction -}}
{{/* Global site tag (gtag.js) - Google Analytics */ -}}
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KGB7V28PEJ"></script>
<script>
Expand All @@ -6,4 +8,5 @@
gtag('js', new Date());

gtag('config', 'G-KGB7V28PEJ');
</script>
</script>
{{- end -}}

0 comments on commit 8db8904

Please sign in to comment.