Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Google Analytics GA4 #67

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
d72f0a5
Merge pull request #5 from Plorenzo/pr
EmielH Sep 18, 2018
f6ba86d
Fix reading language from config and include default language code
EmielH Sep 19, 2018
8c852ee
Add i18n capabilities
EmielH Sep 30, 2018
ee7373d
Add localisation option for publishdate
EmielH Oct 7, 2018
fe693b3
Add manually setting the summary in page frontmatter
EmielH Oct 7, 2018
c125e73
Split some templates into partials
EmielH Oct 14, 2018
dc10780
Split single post header partial for more flexibility
EmielH Oct 15, 2018
18408d7
Add basic support for taxonomies
EmielH Oct 15, 2018
e7495e1
Fix duplicate header
EmielH Oct 16, 2018
f349e97
Add partials for single post header and footer
EmielH Oct 16, 2018
e72c92c
Remove extraneous slash from header partial
dvdzkwsk Oct 18, 2018
a4e7495
Merge pull request #6 from davezuko/patch-1
EmielH Oct 18, 2018
34704ef
Fix broken about page
EmielH Oct 20, 2018
26324a7
Merge branch 'master' of https://github.com/EmielH/tale-hugo
EmielH Oct 20, 2018
0bcb8ba
Use relURL function to generate URLs
EmielH Oct 20, 2018
d4ecdf3
Extract summary from list templates into its own layout file
EmielH Oct 21, 2018
a0868bc
Add partial for introduction on index page
EmielH Oct 21, 2018
6eb83de
Remove duplicate closing tags from footer
EmielH Oct 21, 2018
ccfc801
Use .Site.Author.name in footer instead of .Site.Params.Author
EmielH Oct 28, 2018
f5b5d22
Remove deprecated .Next and .Prev calls
EmielH Nov 4, 2018
c4258ec
Update min_version because of using .NextPage and .PrevPage
EmielH Nov 4, 2018
d3b0c67
Add integration with Travis CI
EmielH Nov 15, 2018
19b7cd6
Add translation to Spanish (#8)
Nov 28, 2018
a254619
Bump Hugo version to 0.52
EmielH Nov 28, 2018
4975fa9
Fix index layout for short titles and summaries
EmielH Nov 29, 2018
9b44178
Use relURL function to generate favicon URLs
EmielH Dec 3, 2018
d95fce5
Improve automated tests
EmielH Dec 4, 2018
7d26db4
Add testing for Hugo 0.53
EmielH Dec 24, 2018
445fb53
Add translation to German
mplatten Jan 5, 2019
09cc19b
Add generated uncompressed CSS for server mode in Hugo Basic
EmielH Jan 27, 2019
5bbc97c
Add tests for Hugo 0.54.0
EmielH Feb 2, 2019
34ad4a8
Add background color
EmielH Mar 3, 2019
ce194f3
Include version of htmlproofer in CI log
EmielH Mar 3, 2019
31df9fc
Disable link checking in CI for now
EmielH Mar 3, 2019
9cb425e
Add option to include additional CSS files
EmielH Mar 3, 2019
08afec4
Add tests for Hugo 0.55.0
EmielH Apr 9, 2019
3b40d26
Use Hugo Theme Test for testing
EmielH Apr 13, 2019
0aa5b63
Remove deprecated .Page.URL
EmielH Apr 14, 2019
753eabb
Remove deprecated .RSSLink
EmielH Apr 14, 2019
f2c0e19
Add tests for Hugo 0.55.1
EmielH Apr 14, 2019
c2a6b22
Add French translation (#19)
AdrienChd Jun 18, 2019
aea2164
Add French translation (#20)
AdrienChd Jun 18, 2019
a39d23d
Parse Markdown in summary in page frontmatter
EmielH Jul 27, 2019
ef80004
Delete space in title tag (#24)
hikaru7719 Aug 3, 2019
c1fba83
Update Hugo test versions
EmielH Aug 3, 2019
db3ee19
Range over .Site.RegularPages in index.html
EmielH Sep 30, 2019
acbf737
Update Hugo test versions
EmielH Sep 30, 2019
9d46913
Add local font files instead of using Google CDN
dadosch Oct 6, 2019
ed015b5
Add dynamic header menu using Hugo Menu's
gavinr Oct 9, 2019
192ffcb
Remove unused i18n strings
EmielH Oct 9, 2019
7965b43
Update README
EmielH Oct 27, 2019
a951fe8
Add code block long lines wrapping (#31)
dagon666 Feb 12, 2020
db2352c
FIx broken link
EmielH Apr 13, 2020
52471a9
Fix font urls for sites not published at root
EmielH May 26, 2020
7ef7a75
Use .Site.Author.name in post info
EmielH Aug 20, 2020
cec4ffa
Update Hugo versions for tests
EmielH Aug 20, 2020
55d8893
Add Disqus-integration
haohanyang Sep 28, 2020
2df7d71
Add Italian language
gosub Oct 25, 2020
54e097b
Add Polish language support
pawelmhm Jan 30, 2021
f160502
Add support for Google Analytics
elessar-ch Mar 10, 2021
ff43e84
Add default favicon location
cloudlena Aug 16, 2021
40c029f
Change site title to h1 on homepage
gavinr Aug 23, 2021
a2f4afd
Change summary titles on homepage to h2
gavinr Aug 23, 2021
81a4beb
Disable TravisCI
EmielH Sep 27, 2021
e98b9ad
Add Kurdish translations
rojvv Sep 29, 2021
b08079b
Add archive page support
isaced Dec 4, 2021
b9b4ec1
Fix favicon.ico links
lberki Mar 27, 2022
551ff44
Add table of contents
lberki May 5, 2022
d6c8e81
Add dark mode
lberki May 5, 2022
b3bc7c6
Add support for Google Analytics GA4
cloudlena Dec 7, 2022
98bbc96
Fix deprecation errors
cloudlena Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 130 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Tale

[![Build Status](https://travis-ci.com/EmielH/tale-hugo.svg?branch=master)](https://travis-ci.com/EmielH/tale-hugo)

This is a port of the [Tale theme for Jekyll](https://github.com/chesterhow/tale) to Hugo. Tale is a minimal Jekyll theme curated for storytellers. Checkout the demo [here](https://chesterhow.github.io/tale/). I did not design this theme; I only ported it from Jekyll to Hugo.

![Tale screenshot](https://raw.githubusercontent.com/EmielH/tale-hugo/master/images/screenshot.png)
Expand Down Expand Up @@ -36,7 +38,7 @@ hugo server -t tale

### Additional information

For more information, read the official [setup guide]( https://gohugo.io/overview/installing/) of Hugo.
For more information, read the official [setup guide](https://gohugo.io/overview/installing/) of Hugo.

### Update the theme

Expand All @@ -48,13 +50,138 @@ git submodule update --remote --rebase

If you have cloned the theme, you can run `git pull` inside the theme folder.

## Configuration

### Menu

The top menu uses [Hugo Menus](https://gohugo.io/content-management/menus/), with the name of the menu being `main`. To turn on the menu, follow the steps there - you can either add something like this to the front-matter of your pages:

```
---
menu: "main"
---
```

... or you can add a menu section to your `config` file:

```
sectionPagesMenu = "main"
```

Or if you want more control, add a specific entry for each item in your menu:

```
[menu]
[[menu.main]]
identifier = "about"
name = "About"
title = "About"
url = "/about/"
weight = 0
[[menu.main]]
identifier = "posts"
name = "Posts"
title = "Posts"
url = "/posts/"
weight = 0
```

For menu internationalization/translation, see [Multilingual Mode: Menus](https://gohugo.io/content-management/multilingual/#menus).

### Internationalisation (i18n)

Tale supports using other languages than English. Language files for the texts Tale uses are provided in the `i18n` directory. The default language is English. To switch languages, add the key `defaultContentLanguage` to your `config.toml` file. For example:

```
defaultContentLanguage = "nl"
```

To translate texts your site uses, add an `i18n` folder to your site.

Feel free to submit pull requests for other translations of Tale's texts.

[Hugo documentation for multilingual sites](//gohugo.io/content-management/multilingual/)

### Disqus

Tale supports Disqus integration, a comment system that empowers dynamic features to static websites. To install it, just add it to your config as described in [the Hugo Documentation](https://gohugo.io/content-management/comments/#configure-disqus).

```toml
disqusShortname = "disqus-example"
```

Add the parameter `comments` in the front-matter of the pages where you want to allow comments

```
---
comments: true
---
```

### Google Analytics

Tale supports Google Analytics (UA and GA4) integration using Hugo's provided `google_analytics` template.

To enable it, add the `googleAnalytics` tag to your `config.toml`. It will be added on all pages.

```toml
googleAnalytics = "UA-133700000-0" # or G-1337000000 for GA4
```

### Custom summaries

Tale allows for writing the summary of your posts manually by setting the `summary` variable in the page frontmatter. If this variable is not set, the summary that Hugo automatically generates will be used.

### Taxonomies

Tale has basic support for taxonomies. Taxonomy and terms pages will be generated when you have defined taxonomies, but you need to include links to these pages yourself. For example, you can add a link to a taxonomy page in `header-menu.html`.

### Placeholder partials

The theme contains placeholder partials to make the theme more flexible and easier to adapt to your site without having to change the theme itself. These are:

- `single/header.html`
- `single/footer.html`

These are included in the template for a single post, at the top of the post (below the title) and at the bottom of the post, respectively. These can be used, for example, to include additional information about the post author or for related posts. Create a file `/layouts/partials/single/header.html` or `footer.html` on your own site to have it included.

- `index/introduction.html`

This partial is included at the top of the list of posts on the index page, allowing you to add an introduction to your site.

### Copyright message

The copyright message in the footer uses the name of the author of the site, as defined in `config.toml`. For example:

```
[Author]
name = "Emiel"
```

### Additional CSS files

The theme can load additional CSS files for you, e.g. to override some of the styles, or the CSS that goes with a component that you're using. To add additional CSS files, put these files in the `static` folder of your site and add the `css` parameter to `config.toml`, like so:

```
[Params]
css = ["custom.css"]
```

To load multiple CSS files, use the parameter like this:

```
[Params]
css = ["custom.css", "custom2.css"]
```

## Acknowledgments

Thanks
Thanks

- to [Chester How](//github.com/chesterhow) for creating the original [Tale theme for Jekyll](https://chesterhow.github.io/tale/),
- to [onedrawingperday](//github.com/onedrawingperday), [bep](//github.com/bep) and [digitalcraftsman](//github.com/digitalcraftsman) for their help in getting the theme working correctly with Hugo,
- to [lucperkins](https://github.com/lucperkins) for the [Fresh theme](https://github.com/lucperkins/hugo-fresh) from which I used some useful snippets of code.

## License
See [LICENSE](https://github.com/EmielH/tale-hugo/blob/master/LICENSE).

See [LICENSE](https://github.com/EmielH/tale-hugo/blob/master/LICENSE).
2 changes: 2 additions & 0 deletions assets/scss/tale.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
@import 'tale/post';
@import 'tale/syntax';
@import 'tale/layout';
@import 'tale/toc';
@import 'tale/pagination';
@import 'tale/catalogue';
@import 'tale/disqus';
11 changes: 6 additions & 5 deletions assets/scss/tale/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

html,
body {
color: $default-color;
color: var(--default-color);
background-color: var(--background-color);
margin: 0;
padding: 0;
}
Expand All @@ -30,19 +31,19 @@ h3,
h4,
h5,
h6 {
color: $default-shade;
color: var(--default-shade);
font-family: $sans-serif;
line-height: normal;
}

a {
color: $blue;
color: var(--blue);
text-decoration: none;
}

blockquote {
border-left: .25rem solid $grey-2;
color: $grey-1;
border-left: .25rem solid var(--grey-2);
color: var(--grey-1);
margin: .8rem 0;
padding: .5rem 1rem;

Expand Down
14 changes: 7 additions & 7 deletions assets/scss/tale/_catalogue.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.catalogue {
&-item {
border-bottom: 1px solid $grey-2;
color: $default-color;
display: inline-block;
border-bottom: 1px solid var(--grey-2);
color: var(--default-color);
display: block;
padding: 2rem 0;

&:hover .catalogue-line,
Expand All @@ -16,13 +16,13 @@
}

&-time {
color: $default-tint;
color: var(--default-tint);
font-family: $serif-secondary;
letter-spacing: .5px;
}

&-title {
color: $default-shade;
color: var(--default-shade);
display: block;
font-family: $sans-serif;
font-size: 2rem;
Expand All @@ -31,8 +31,8 @@
}

&-line {
@include transition(all .3s ease-out);
border-top: .2rem solid $default-shade;
@include transition($color-transition, width .3s ease-out);
border-top: .2rem solid var(--default-shade);
display: block;
width: 2rem;
}
Expand Down
15 changes: 11 additions & 4 deletions assets/scss/tale/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ code {
}

code {
background-color: $grey-3;
background-color: var(--grey-4);
border-radius: 3px;
color: $code-color;
color: var(--code-color);
font-size: 85%;
padding: .25em .5em;
white-space: pre-wrap;
}

pre {
Expand All @@ -22,8 +23,14 @@ pre code {
padding: 0;
}

pre code > span {
// This isn't very pretty, but the precise RGB values are generated
// server-side, the usual trick of putting the colors in CSS variables does
// not quite work and this is the best I could come up with.
filter: var(--code-filter);
}
.highlight {
background-color: $grey-3;
background-color: var(--grey-4);
border-radius: 3px;
line-height: 1.4;
margin: 0 0 1rem;
Expand All @@ -35,7 +42,7 @@ pre code {
}

.lineno {
color: $default-tint;
color: var(--default-tint);
display: inline-block; // Ensures the null space also isn't selectable
padding: 0 .75rem 0 .25rem;
// Make sure numbers aren't selectable
Expand Down
3 changes: 3 additions & 0 deletions assets/scss/tale/_disqus.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.article-discussion {
margin: 0;
}
35 changes: 27 additions & 8 deletions assets/scss/tale/_layout.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
* {
@include transition($color-transition);
}

.container {
margin: 0 auto;
max-width: 800px;
width: 80%;
}

main,
// Carve out an exception from the 80% narrowing of the viewport for the table
// of contents. This is ugly, but there isn't a better way, since the table of
// contents must be a child of the "main" element so that it its scrolling
// behavior is intuitive.
main > *,
footer,
.nav-container {
display: block;
Expand All @@ -13,8 +21,19 @@ footer,
width: 80%;
}

#darkModeToggle {
float: right;
position: sticky;
top: 2rem;
margin-right: 2rem;
margin-top: 2rem;
font-size: 2rem;

cursor: pointer;
}

.nav {
box-shadow: 0 2px 2px -2px $shadow-color;
box-shadow: 0 2px 2px -2px var(--shadow-color);
overflow: auto;

&-container {
Expand All @@ -24,8 +43,8 @@ footer,
}

&-title {
@include transition(all .2s ease-out);
color: $default-color;
@include transition($color-transition, opacity .2s ease-out);
color: var(--default-color);
display: inline-block;
margin: 0;
padding-right: .2rem;
Expand All @@ -44,8 +63,8 @@ footer,
}

li {
@include transition(all .2s ease-out);
color: $default-color;
@include transition($color-transition, opacity .2s ease-out);
color: var(--default-color);
display: inline-block;
opacity: .6;
padding: 0 2rem 0 0;
Expand All @@ -61,7 +80,7 @@ footer,
}

a {
color: $default-color;
color: var(--default-color);
font-family: $sans-serif;
}
}
Expand All @@ -86,7 +105,7 @@ footer {
text-align: center;

span {
color: $default-color;
color: var(--default-color);
font-size: .8rem;
}
}
12 changes: 6 additions & 6 deletions assets/scss/tale/_pagination.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.pagination {
border-top: .5px solid $grey-2;
border-top: .5px solid var(--grey-2);
font-family: $serif-secondary;
padding-top: 2rem;
position: relative;
text-align: center;

span {
color: $default-shade;
color: var(--default-shade);
font-size: 1.1rem;
}

.top {
@include transition(all .3s ease-out);
color: $default-color;
@include transition($color-transition, opacity .3s ease-out);
color: var(--default-color);
font-family: $sans-serif;
font-size: 1.1rem;
opacity: .6;
Expand All @@ -23,8 +23,8 @@
}

.arrow {
@include transition(all .3s ease-out);
color: $default-color;
@include transition($color-transition, opacity .3s ease-out);
color: var(--default-color);
position: absolute;

&:hover,
Expand Down
Loading