项目作者: it-gro

项目描述 :
高级语言: HTML
项目地址: git://github.com/it-gro/hugo-theme-w3css-basic.git
创建时间: 2017-11-08T13:26:44Z
项目社区:https://github.com/it-gro/hugo-theme-w3css-basic

开源协议:MIT License

下载


W3.CSS Basic Theme for Hugo

W3.CSS Basic is a website template built with W3.CSS.
Inspiration was taken from
Universal. It is highly
configurable.
Change all colors in the blink of an eye, change default settings or disable
Frontpage elements.

See the exampleSite for a demo.


This theme is for:

  • Landing pages
  • Blogs
  • Pages (not blog) in a directory structure with simple navigation (Top/Up/Down & pages on this level)
  • People who like monochromatic colors

Table of Contents

Latest News

  • Hugo 0.58 ready

  • Added shortcodes:

  • Added breadcrump
    screenshot breadcrump

config.toml

  1. [params.options]
  2. # used in layouts/partials/page.nav.breadcrump.html
  3. showNavBreadcrump = true
  4. navBreadcrumpTitle = true
  5. navBreadcrumpHome = false

config.toml

  1. [params.options]
  2. # used in layouts/partials/main.headline.nav-right.html
  3. jsHistoryNav = true
  4. jsHistoryNavForward = false
  5. showNavUp = true

screenshot title-nav

screenshot title-nav

screenshot related

screenshot cookieconsent

  • Teaser images are now resource images
  • New Front Matter (resImgTeaser is replacing teaserPic):
  1. resImgTeaser: teaserpics/pixabay.com/adventure-2528477.jpg

Default is to resize with reasonale dimensions. You may overwrite the defaults:

  1. resImgTeaser: teaserpics/pixabay.com/adventure-2528477.jpg
  2. resImgTeaserCmd: Fill
  3. resImgTeaserOpt: 400x400
  4. resImgTeaserInCardCmd: Fill
  5. resImgTeaserInCardOpt: "150x50 Bottom"

See the teaser image here: These
Logos
and compare to the one on the page.

  • User has now to agree to Disqus. You may skip this via

config.toml

  1. disqusSkipAgree = true

screenshot DiscusAgree

  • Added color theme preview via color theme selector (not on small displays)
    screenshot color theme selector
  1. # This may help you to to select a w3cssColorTheme
  2. themeColorSelectorEnable = true

Goals

My goals for this theme are:

  • be as universal as the Universal theme
  • create a W3.CSS theme (there are many Bootstrap themes)
  • mobile first, responsive
  • basic usage without javascript has to be possible
  • do as much as possible not to expose visitors to tracking by third-party against their will
  • try to be DRY
  • support experimenting with monochromatic colors
  • use teaser pictures and icons as eye-catcher

Features

Included Resources

This theme includes resources from:

Features Tags:

animate, attachments, blog, branch-bundle, carousel, clients, color-themes,
configuration, contact-form, cookie-consent, custom-themes, data, debug, disqus,
emoji, features, figure, font-awesome, formspree.io, gallery, google-analytics,
google-custom-search, google-fonts, google-map, google-translate,
headless-bundle, hugo-easy-gallery, i18n, image-processing, jumbotron,
landing-page, leaf-bundle, marquee, menu, menutopbar, mobile,
monochromatic-colors, navigation, page-bundles, page-resources, pages,
pagination, photocards, privacy, responsive, search, see-more, submenu,
taxonomy-bar, taxonomy-list, teaser-pictures, teasers, term-list, testimonials,
tracing

Features List

  • Monochromatic Color Schemes
  • Works with disabled javascript (using fallbacks)
  • Responsive design
    • 3 (medium, lage) or 1 (small) column layout
    • small menu (truncated) on small screen (no collapse)
  • Customizable landing page
    • optional marquee (using css)
    • optional data/jumbotron (carousel (if js is enabled) )
    • optional data/photocards (optional css animation)
    • optional data/features (optional css animation)
    • optional data/testimonials (carousel (if js is enabled) )
    • optional data/clients (carousel (if js is enabled) )
  • Fontawesome version 5 (local)
  • Google fonts - either via api (any font) or via local files (choose local to reduce tracking)
  • Optional google translate widget (if js is enabled - disable it to reduce tracking)
  • Optional Google Global Site Tags with your GA_TRACKING_ID (do not activate to reduce tracking))
  • Contact page
  • Search page
  • Alternative navigation instead of breadcrumbs (Top/Up/Down & pages on this level)
  • hugo-easy-gallery (including PhotoSwipe which needs js)

Installation

Go to the directory where you have your Hugo site and run:

  1. $ mkdir themes
  2. $ cd themes
  3. $ git clone https://github.com/it-gro/hugo-theme-w3css-basic

For more information read the official setup guide of Hugo.

Configuration

After installing the theme we recommend you to take a look at the
exampleSite
directory. You will find a working Hugo
site

configured with this theme that you can use as a starting point for
your site.

First, let’s take a look at the
config.toml. It
will be useful to learn how to customize your site.

Language

Available translations are in the /i18n directory. You can configure
the language modifying the following key.

  1. defaultContentLanguage = "en"

Frontpage

Marquee

config.toml

  1. [params.marquee]
  2. # enable or disable marquee on frontpage
  3. enable = true
  4. # marquee text is placed in directory as:
  5. file = ".marquee.md"
  • Create a file .marquee.md in each directory where a marquee should be shown
  • Marquee text scrolls from right to left

screenshot Marquee & Navbar long

Jumbotron

  1. [params.jumbotrons]
  2. # used in layouts/partials/front.jumbotrons.carousel.html
  3. # enable or disable jumbotrons on frontpage
  4. # see some examples in 'exampleSite/data/jumbotron'
  5. enable = true
  • Front jumbotron text only

screenshot Jumbotron Text

  • Front jumbotron text & picture

screenshot Jumbotron Text & Pic

  • Front jumbotron text & icon

screenshot Jumbotron Text & Icon

  1. data/jumbotron/
  2. ├── 01-jumbotron.yaml
  3. ├── 02-jumbotron.yaml
  4. ├── 03-jumbotron.yaml
  5. ├── 04-jumbotron.yaml
  6. └── 05-jumbotron.yaml

01-jumbotron.yaml

  1. weight: 1
  2. title: "Welcome to hugo-theme-w3css-basic exampleSite"
  3. icon:
  4. resImg:
  5. description: |
  6. * Lorem ipsum dolor sit amet
  7. * Excepteur sint occaecat cupidatat non proident

Photocards

  1. [params.photocards]
  2. # used in layouts/partials/front.photocards.html
  3. # enable or disable photocards on frontpage
  4. # see some examples in 'exampleSite/data/photocards'
  5. enable = true
  6. animate = true
  7. resImgCmd = "Resize"
  8. resImgCmdOpt = "300x"
  • Front photocards

screenshot Photocards (9)

  1. data/photocards/
  2. ├── 01-photocard.yaml
  3. ├── 02-photocard.yaml
  4. ├── 03-photocard.yaml
  5. ├── 04-photocard.yaml
  6. ├── 05-photocard.yaml
  7. ├── 06-photocard.yaml
  8. ├── 07-photocard.yaml
  9. ├── 08-photocard.yaml
  10. └── 09-photocard.yaml

01-photocard.yaml

  1. weight: 1
  2. title: "Lorem ipsum"
  3. animated: "rollIn"
  4. resImg: "photocards/pixabay.com/01-photocard.jpg"
  5. url: pages/front/photocards/01
  6. description: |
  7. sed diam nonumy

Features

  1. [params.features]
  2. # used in layouts/partials/front.features.html
  3. # enable or disable features on frontpage
  4. # see some examples in 'exampleSite/data/features'
  5. enable = true
  6. animate = false
  • Front features

screenshot Feature (6)

  1. data/features/
  2. ├── 01-feature.yaml
  3. ├── 02-feature.yaml
  4. ├── 03-feature.yaml
  5. ├── 04-feature.yaml
  6. ├── 05-feature.yaml
  7. └── 06-feature.yaml

01-feature.yaml

  1. weight: 1
  2. name: "Eleifend"
  3. icon: "fas fa-desktop"
  4. animated: "slideInLeft"
  5. url: pages/front/features/01
  6. description: |
  7. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
  8. nonumy eirmod tempor invidunt ut labore

Recent Posts

  1. [params.recentPosts]
  2. # used in layouts/partials/footer.html
  3. footerNumOfPosts = 5
  4. enableFooter = true
  5. # used in layouts/partials/front.recent_posts.html
  6. enableFront = true
  7. title = "From our Blog"
  8. subtitle = '''
  9. Pellentesque habitant morbi tristique senectus et netus et malesuada
  10. fames ac.
  11. '''
  • Front recent posts

screenshot Recent Posts

See More

  1. [params.seeMore]
  2. # used in layouts/partials/front.see_more.html
  3. # enable or disable see_more on frontpage
  4. enable = true
  5. icon = "far fa-file-code"
  6. title = "Do You want to see More?"
  7. linkUrl = "/pages"
  8. linkText = "consectetuer adipiscing"
  9. subtitle = '''
  10. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
  11. suscipit lobortis nisl ut aliquip ex ea commodo consequat.
  12. '''
  • Front see more

screenshot See More

  • The background image is defined in /static/css/w3css-basic.css:
  1. /* -------------------------------------------------- */
  2. /* front.see_more */
  3. #see_more_background {
  4. background: url('../images/backgrounds/see_more_background.jpg') center top no-repeat;
  5. }

Testimonials

  1. [params.testimonials]
  2. # used in layouts/partials/front.testimonials.carousel.html
  3. # enable or disable testimonials on frontpage
  4. # see some examples in 'exampleSite/data/testimonials'
  5. enable = true
  6. title = "Testimonials"
  7. subtitle = '''
  8. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
  9. labore et dolore magna aliquyam erat, sed diam voluptua.
  10. '''
  • Front testimonials

screenshot Testimonials

  1. data/testimonials/
  2. ├── 01-testimonial.yaml
  3. ├── 02-testimonial.yaml
  4. ├── 03-testimonial.yaml
  5. ├── 04-testimonial.yaml
  6. └── 05-testimonial.yaml

01-testimonial.yaml

  1. weight: 1
  2. name: "John Doe"
  3. position: "CEO, Takimata"
  4. resImg: "testimonials/pixabay.com/person-1.jpg"
  5. text: |
  6. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
  7. suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
  8. vel eum iriure dolor in hendrerit in vulputate velit esse molestie
  9. consequat, vel illum dolore eu feugiat

Clients

  1. [params.clients]
  2. # used in layouts/partials/front.clients.carousel.html
  3. # enable or disable clients on frontpage
  4. # see some examples in 'exampleSite/data/clients'
  5. enable = true
  6. resImgCmd = "Resize"
  7. resImgCmdOpt = "100x"
  8. imgMaxWidth = "100px"
  9. imgMaxHeight = "100px"
  10. title = "Our Clients"
  11. subtitle = '''
  12. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse
  13. **molestie consequat**, vel illum dolore.
  14. '''
  • Front clients

screenshot Clients

  1. data/clients/
  2. ├── 01-client.yaml
  3. ├── 02-client.yaml
  4. ├── 03-client.yaml
  5. ├── 04-client.yaml
  6. ├── 05-client.yaml
  7. └── 06-client.yaml

01-client.yaml

  1. weight: 1
  2. name: "customer-1"
  3. resImg: "images/clients/pixabay.com/company-logo-1.png"
  4. url: "http://www.example.com"

Blog

Blog List

  1. [params.blog]
  2. # used in layouts/blog/list.html
  3. title = "Blog"
  4. icon = "fas fa-rss"
  5. subtitle = '''
  6. ultricies eget, tempor sit amet, ante
  7. '''
  • Blog with paginate = 6 (short date)

screenshot Blog Paginator (6)

  1. content/blog/
  2. ├── 1985
  3. └── 03
  4. └── emacs-jokes.md
  5. └── 2017
  6. ├── 09
  7. └── emacs-it-all-starts-here.md
  8. ├── 10
  9. └── golang-a-closer-look.md
  10. └── 11
  11. ├── hugo-dolor.md
  12. ├── hugo-highlight-chromastyles.md
  13. ├── hugo-ipsum.md
  14. └── hugo-lorem.md

hugo-highlight-chromastyles.md:

  1. ---
  2. title: "Hugo - **highlight** :art:"
  3. date: 2017-11-24T08:44:12+01:00
  4. resImgTeaser: teaserpics/bitbucket.org/pygments-main-logo.png
  5. tags:
  6. - Hugo
  7. categories:
  8. - Web
  9. ---
  10. Hugo comes with reallly fast syntax highlighting from Chroma.
  11. ...
  12. <!--more-->
  13. In this theme we set
  14. ...

Date format

  • Dates are shown for blog articles (not other pages)
  • Short version in teaser
    {{- .Date.Day}}. {{substr (default .Date.Month (i18n .Date.Month)) 0 3}} {{.Date.Year -}}
  • Long version in article
    {{- .Date.Day}}. {{default .Date.Month (i18n .Date.Month)}} {{.Date.Year -}}
  • provide the translation in i18n/*.yaml
  1. - id: January
  2. translation: "Januar"
  3. ...
  • Blog article (long date)

screenshot Blog Entry

Disqus

screenshot Blog Disqus Open

  1. # Enable comments by entering your Disqus shortname
  2. disqusShortname = "it-gro-github-io-hugo-theme-w3css-basic-github-io"
  3. [params]
  4. # disqus (theme)
  5. # ##############################
  6. # used in partials/blog.disqus-button.html
  7. # set to true, if you want to show the count of comments
  8. # fires an async request to disqus.com/count.js
  9. disqusButtonShowCount = false
  • User has to agree to Disqus. You may skip this via

config.toml

  1. disqusSkipAgree = true

screenshot DiscusAgree

  • No JavaScript fallback

screenshot Blog Disqus NoJs

  • disqusButtonShowCount = false

screenshot Blog Disqus NoCount

  • disqusButtonShowCount = true

screenshot Blog Disqus Count

Hook:

layouts/blog/single.html

  1. {{ define "blog-disqus" }}
  2. {{ partial "blog.disqus-button.html" . }}
  3. {{ end }}

=> review layouts/partials/blog.disqus-button.html

Anchors

screenshot title-nav

config.toml

  1. [params.anchor]
  2. # layouts/_default/baseof.html
  3. enable = true
  4. #icon = "fas fa-anchor"
  5. icon = "fas fa-link"

screenshot title-nav

config.toml

  1. [params.related]
  2. # https://gohugo.io/content-management/related/
  3. # layouts/partials/main.related.html
  4. enable = true
  5. limitTo = 5

Pages

Pages Navigation

  • Page navigation top level

screenshot Page Navigation (root)

  • Page navigation with Top/Up/Down and pages on this level

screenshot Page Navigation (up & down)

  1. content/pages/
  2. ├── folder10
  3. ├── _index.md
  4. ├── malesuada-massa.md
  5. └── neque-nec.md
  6. ├── folder20
  7. ├── estdui-fermentum.md
  8. ├── felis-vel-velit.md
  9. ├── folder21
  10. ├── folder211
  11. ├── _index.md
  12. ├── phasellus.md
  13. └── rutrum.md
  14. ├── _index.md
  15. ├── nullam.md
  16. └── vestibulum.md
  17. ├── _index.md
  18. ├── magna-orci-ultrices.md
  19. ├── nam-asapien.md
  20. ├── neque-orci.md
  21. └── vestibulum-convallis.md
  22. ├── folder30
  23. ├── donec-pretium-posuere.md
  24. ├── _index.md
  25. └── pellentesque-dapibus-suscipit.md
  26. ├── front
  27. ...

content/pages/folder20/folder21/_index.md

  1. ---
  2. weight: 21
  3. title: "Cum sociis natoque (this is level /folder20/folder21)"
  4. date: "2017-06-08T01:06:13+02:00"
  5. resImgTeaser: teaserpics/gohugo.io/hugo-dolor.png
  6. ---

content/pages/front/_index.md

  1. ---
  2. weight: 18
  3. title: "Frontpage Eye-Catcher (this is level /front)"
  4. date: 2017-11-13T15:37:04+01:00
  5. icon: "fas fa-globe"
  6. ---

Taxonomy

  • Taxonomy bar (only shown if page has a taxonomy)
  1. [params.taxonomies]
  2. # used in layouts/partials/main.taxonomy.full.bar.html
  3. fullBarMinItemsTag = 1
  4. fullBarMinItemsCategory = 1

screenshot Taxonomy Bar

  • Terms lists

screenshot Categories

screenshot Tags

Color Theme

All W3.CSS predefined monochromatic color themes
(https://www.w3schools.com/w3css/w3css_color_themes.asp) are placed in
the /static/vendor/w3css/4/ directory.

You may create your own monochromatic color theme using
https://www.w3schools.com/w3css/w3css_color_generator.asp and then put the css file under /static/css/w3-theme-custom.css.

Select the actual color theme:

  1. [params]
  2. #w3cssColorTheme = "/css/w3-theme-custom.css"
  3. w3cssColorTheme = "/vendor/w3css/4/w3-theme-orange.css"

Available options (theme files) are:

  1. w3cssColorTheme = "/vendor/w3css/4/w3-theme-amber.css"
  2. w3cssColorTheme = "/vendor/w3css/4/w3-theme-black.css"
  3. w3cssColorTheme = "/vendor/w3css/4/w3-theme-blue-grey.css"
  4. w3cssColorTheme = "/vendor/w3css/4/w3-theme-blue.css"
  5. w3cssColorTheme = "/vendor/w3css/4/w3-theme-brown.css"
  6. w3cssColorTheme = "/vendor/w3css/4/w3-theme-cyan.css"
  7. w3cssColorTheme = "/vendor/w3css/4/w3-theme-dark-grey.css"
  8. w3cssColorTheme = "/vendor/w3css/4/w3-theme-deep-orange.css"
  9. w3cssColorTheme = "/vendor/w3css/4/w3-theme-deep-purple.css"
  10. w3cssColorTheme = "/vendor/w3css/4/w3-theme-green.css"
  11. w3cssColorTheme = "/vendor/w3css/4/w3-theme-grey.css"
  12. w3cssColorTheme = "/vendor/w3css/4/w3-theme-indigo.css"
  13. w3cssColorTheme = "/vendor/w3css/4/w3-theme-khaki.css"
  14. w3cssColorTheme = "/vendor/w3css/4/w3-theme-light-blue.css"
  15. w3cssColorTheme = "/vendor/w3css/4/w3-theme-light-green.css"
  16. w3cssColorTheme = "/vendor/w3css/4/w3-theme-lime.css"
  17. w3cssColorTheme = "/vendor/w3css/4/w3-theme-orange.css"
  18. w3cssColorTheme = "/vendor/w3css/4/w3-theme-pink.css"
  19. w3cssColorTheme = "/vendor/w3css/4/w3-theme-purple.css"
  20. w3cssColorTheme = "/vendor/w3css/4/w3-theme-red.css"
  21. w3cssColorTheme = "/vendor/w3css/4/w3-theme-teal.css"
  22. w3cssColorTheme = "/vendor/w3css/4/w3-theme-yellow.css"
  23. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2006-sand-dollar.css"
  24. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2007-chili-pepper.css"
  25. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2008-blue-izis.css"
  26. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2009-mimosa.css"
  27. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2010-turquise.css"
  28. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2011-honeysucle.css"
  29. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2012-tangerine-tango.css"
  30. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2013-emerald.css"
  31. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2014-radiand-orchid.css"
  32. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2015-marsala.css"
  33. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-airy-blue.css"
  34. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-aurora-red.css"
  35. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-bodacious.css"
  36. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-buttercup.css"
  37. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-duster-cedar.css"
  38. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-fiesta.css"
  39. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-green-flash.css"
  40. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-iced-coffe.css"
  41. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-lilac-grey.css"
  42. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-limpet-shell.css"
  43. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-lush-medow.css"
  44. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-peach-echo.css"
  45. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-potters-clay.css"
  46. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-riverside.css"
  47. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-rose-quarts.css"
  48. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-serenity.css"
  49. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-sharkskin.css"
  50. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-snorkel-blue.css"
  51. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-spicy-mustard.css"
  52. w3cssColorTheme = "/vendor/w3css/4/color_of_the_year/w3-theme-color-of-year-2016-warm-taupe.css"

You can configure all colors within the selected monochromatic color theme:

  1. # used in layouts/partials/*.html
  2. # used in layouts/blog/*.html
  3. # used in layouts/default/*.html
  4. # used in layouts/pages/*.html
  5. # e.g. {{ default `w3-theme-l3` ($.Site.Param `color404Container`)}}
  6. # layouts/partials/header.marquee.html
  7. colorHeaderMarquee = "w3-theme-l1"
  8. #
  9. # layouts/partials/header.nav.html
  10. colorHeaderNav = "w3-theme-dark"
  11. #
  12. # layouts/_default/baseof.html
  13. colorBaseofCanvas = "w3-theme-l4"
  14. colorBaseofPanel = "w3-theme-l2"
  15. #
  16. # layouts/partials/front.*.html
  17. colorFrontClientsCard = "w3-theme-l2"
  18. colorFrontClientsContainer = "w3-theme-l3"
  19. colorFrontFeaturesCard = "w3-theme-l3"
  20. colorFrontFeaturesContainer = "w3-theme-l4"
  21. colorFrontJumbotronsContainer = "w3-theme-l2"
  22. colorFrontJumbotronsSection = "w3-theme-l4"
  23. colorFrontPhotocardsCard = "w3-theme-l1"
  24. colorFrontPhotocardsCardContainer = "w3-theme-l1"
  25. colorFrontPhotocardsContainer = "w3-theme-l3"
  26. colorFrontRecentPostsCard = "w3-theme-l4"
  27. colorFrontRecentPostsCardButton = "w3-theme-l4"
  28. colorFrontRecentPostsContainer = "w3-theme-l3"
  29. colorFrontRecentPostsTitleCard = "w3-theme-l2"
  30. colorFrontSeeMoreButton = "w3-theme-l4"
  31. colorFrontSeeMoreContainer = "w3-theme-l4"
  32. colorFrontSeeMoreText = "w3-text-white"
  33. colorFrontTestimonialsCarouselCard = "w3-theme-l5"
  34. colorFrontTestimonialsContainer = "w3-theme-l4"
  35. colorFrontTestimonialsTitleCard = "w3-theme-l2"
  36. #
  37. # layouts/partials/page.nav.cards.html
  38. colorPageNavCardsCard = "w3-theme-d3"
  39. colorPageNavCardsLink = "w3-theme-l3"
  40. colorPageNavCardsContainer = "w3-theme-l3"
  41. #
  42. # layouts/pages/list.html:
  43. colorPagesListCard = "w3-theme-l3"
  44. colorPagesListCell = "w3-theme-l4"
  45. colorPagesListContainer = "w3-theme-l4"
  46. #
  47. # layouts/blog/list.html
  48. colorBlogListCard = "w3-theme-l3"
  49. colorBlogListCell = "w3-theme-l4"
  50. colorBlogListContainer = "w3-theme-l4"
  51. #
  52. # layouts/_default/taxonomy.html
  53. colorTaxonomyCard = "w3-theme-l3"
  54. colorTaxonomyCell = "w3-theme-l4"
  55. colorTaxonomyContainer = "w3-theme-l4"
  56. #
  57. # layouts/partials/main.paginator.bar.html
  58. colorPaginatorBar = "w3-theme-l1"
  59. #
  60. # layouts/_default/taxonomy.html
  61. colorTaxonomyBar = "w3-theme-l1"
  62. colorTaxonomyPanel = "w3-theme-l2"
  63. #
  64. #layouts/_default/terms.html:
  65. colorTermsPanel = "w3-theme-l2"
  66. #
  67. # layouts/partials/blog.disqus-button.html
  68. colorDisqusButton = "w3-theme-l3"
  69. #
  70. # layouts/partials/contact.form.html
  71. colorContactFormPanel = "w3-theme-d3"
  72. #
  73. # layouts/partials/contact.map.html
  74. colorContactMapCard = "w3-theme-l2"
  75. colorContactMapPanel = "w3-theme-l2"
  76. #
  77. # layouts/partials/search.google.gcse.html
  78. colorSearchGoogleGcseContainer = "w3-theme-l3"
  79. #
  80. # layouts/partials/footer.bottom.html
  81. colorFooterBottomCell = "w3-theme-l3"
  82. #
  83. # layouts/partials/footer.html
  84. colorFooterButton = "w3-theme-l4"
  85. colorFooterContainer = "w3-theme-d5"
  86. #
  87. # layouts/404.html
  88. color404Container = "w3-theme-l3"
  89. #
  90. # layouts/partials/main.related.html
  91. colorRelatedBar = "w3-theme-l3"
  92. # used in layouts/shortcodes/alert.html
  93. colorAlertPrimary = "w3-purple"
  94. colorAlertSecondary = "w3-aqua"
  95. colorAlertSuccess = "w3-light-green"
  96. colorAlertInfo = "w3-light-blue"
  97. colorAlertWarning = "w3-yellow"
  98. colorAlertDanger = "w3-red"
  99. colorAlertDark = "w3-dark-grey"
  100. colorAlertLight = "w3-grey"

Favicons

  1. [params.favicon]
  2. # you may want to use https://realfavicongenerator.net to generate your files
  3. # used in layouts/partials/head.favicon.html
  4. # relURL is applied to path
  5. enable = false
  6. path = "/images/favicons"
  7. version = "a_random_value"
  8. maskIcon = "#5bbad5"
  9. msapplicationTileColor = "#da532c"
  10. themeColor = "#ffffff"

layouts/partials/head.favicon.html

  1. {{- $myFaviconVersion := default "a_random_value" $.Site.Params.favicon.version }}
  2. {{- $myFaviconPath := default "/images/favicons" $.Site.Params.favicon.path }}
  3. <link rel="apple-touch-icon" sizes="180x180" href="{{(printf `%s/%s?v=%s` $myFaviconPath `apple-touch-icon.png` $myFaviconVersion ) | relURL }}" />
  4. <link rel="icon" type="image/png" sizes="16x16" href="{{(printf `%s/%s?v=%s` $myFaviconPath `favicon-16x16.png` $myFaviconVersion ) | relURL }}" />
  5. <link rel="icon" type="image/png" sizes="192x192" href="{{(printf `%s/%s?v=%s` $myFaviconPath `android-chrome-192x192.png` $myFaviconVersion ) | relURL }}" />
  6. <link rel="icon" type="image/png" sizes="32x32" href="{{(printf `%s/%s?v=%s` $myFaviconPath `favicon-32x32.png` $myFaviconVersion ) | relURL }}" />
  7. <link rel="manifest" href="{{(printf `%s/%s?v=%s` $myFaviconPath `manifest.json` $myFaviconVersion ) | relURL }}" />
  8. <link rel="shortcut icon" href="{{(printf `%s/%s?v=%s` $myFaviconPath `favicon.ico` $myFaviconVersion ) | relURL }}" />
  9. <meta name="msapplication-TileImage" content="{{(printf `%s/%s?v=%s` $myFaviconPath `mstile-144x144.png` $myFaviconVersion ) | relURL }}" />
  10. <meta name="msapplication-config" content="{{(printf `%s/%s?v=%s` $myFaviconPath `browserconfig.xml` $myFaviconVersion ) | relURL }}" />
  11. <link rel="mask-icon" href="{{(printf `%s/%s?v=%s` $myFaviconPath `safari-pinned-tab.svg` $myFaviconVersion ) | relURL }}"
  12. color="{{default `#5bbad5` $.Site.Params.favicon.maskIcon }}" />
  13. <meta name="msapplication-TileColor" content="{{default `#da532c` $.Site.Params.favicon.msapplicationTileColor }}" />
  14. <meta name="theme-color" content="{{default `#ffffff` $.Site.Params.favicon.themeColor }}" />

So you need at least these files in your project:

  1. static/images/favicons/
  2. ├── android-chrome-192x192.png
  3. ├── apple-touch-icon.png
  4. ├── browserconfig.xml
  5. ├── favicon-16x16.png
  6. ├── favicon-32x32.png
  7. ├── favicon.ico
  8. ├── manifest.json
  9. ├── mstile-144x144.png
  10. └── safari-pinned-tab.svg
  • if baseURL containts paths (like example.com/foo/bar) you
    need to make sure this path (/foo/bar/) is also given in browserconfig.xml and
    manifest.json

Emoji

  1. enableEmoji = true

You may use emoji in titles as well:

  1. title: "Hugo - **highlight** :art:"

e.g. in main.teaser_in_card.html

  1. <h3>
  2. {{- if .Params.icon }}
  3. <i class="{{ .Params.icon }}"></i>
  4. {{- end }}
  5. {{ .Title | markdownify | emojify }}
  6. </h3>

See https://gohugo.io/functions/emojify/

screenshot Emoji

Emoji are good for mobile devices. On desktops support is kind of “poor”.
Firefox users may have a look at https://github.com/eosrei/twemoji-color-font.

Summary

  1. summaryLength = 70
  2. [params]
  3. teaserTruncateSummary = 200

summaryLength was introduced in hugo 0.30
(https://gohugo.io/news/0.30-relnotes/). It’s measure is “words”.
teaserTruncateSummary is in “characters”. The Description (first
priority) or the Summary (second priority) is truncated (without
cutting words):

  1. {{- or .Description .Summary | markdownify | truncate ( or .Site.Params.teaserTruncateSummary 160) | replaceRE "<.?p>" "" | safeHTML }}

<!--more--> is still an option to override the summaryLength (https://gohugo.io/content-management/summaries/)

Pagination

  1. paginate = 6

Since we have a 3 column layout (1 column on small displays) it works
best with any of 3, 6, 9, 12.

Syntax Highlighting

  1. # https://gohugo.io/content-management/syntax-highlighting/
  2. pygmentsUseClassic = false
  3. pygmentsCodeFences = true
  4. pygmentsCodeFencesGuessSyntax = true
  5. # https://help.farbox.com/pygments.html
  6. # https://github.com/alecthomas/chroma
  7. # hugo gen chromastyles --style=autumn > syntax.autumn.css
  8. # ...
  9. pygmentsUseClasses = true
  10. # => static/css/syntax/syntax/syntax.*.css
  11. # copy one of them to
  12. # static/css/syntax/syntax.css
  13. # alternative (if shortcodes/csc*.html are not used):
  14. # set pygmentsUseClassic to false on choose one of the following:
  15. #pygmentsStyle = "autumn"
  16. #pygmentsStyle = "borland"
  17. #pygmentsStyle = "bw"
  18. #pygmentsStyle = "colorful"
  19. #pygmentsStyle = "default"
  20. #pygmentsStyle = "emacs"
  21. #pygmentsStyle = "friendly"
  22. #pygmentsStyle = "fruity"
  23. #pygmentsStyle = "manni"
  24. #pygmentsStyle = "monokai"
  25. #pygmentsStyle = "murphy"
  26. #pygmentsStyle = "native"
  27. #pygmentsStyle = "pastie"
  28. #pygmentsStyle = "perldoc"
  29. #pygmentsStyle = "rrt"
  30. #pygmentsStyle = "tango"
  31. #pygmentsStyle = "trac"
  32. #pygmentsStyle = "vim"
  33. #pygmentsStyle = "vs"
  1. {{< highlight perl "linenos=table,hl_lines=5 7-8 21,linenostart=1" >}}
  2. #!/usr/bin/perl
  3. ...
  4. {{< /highlight >}}

=> https://it-gro.github.io/hugo-theme-w3css-basic.github.io/pages/showcase/code-01/

Menu

  • Navbar “Long” (for medium or large displays)

screenshot Marquee & Navbar long

  1. # provide translations in i18n/*.yaml
  2. [[menu.main]]
  3. weight = 1
  4. name = "Home"
  5. url = "/index.html"
  6. pre = "fas fa-home"
  7. [[menu.main]]
  8. weight = 2
  9. name = "Contact"
  10. url = "/contact"
  11. pre = "far fa-address-card"
  • pre is for fontawesome version 5 icons
  • name is used for lookup in i18n/*.yaml (=> translation)
  • if no translation is given, the name itself is shown
    page.nav.html
    <button class="w3-button w3-hide-small"><i class="{{ .Pre }}"></i> {{default .Name (i18n .Name)}}</button>
  • Submenu (one level)

screenshot Marquee & Navbar small

  1. # demo submenu
  2. [[menu.main]]
  3. weight = 4
  4. name = "Theme"
  5. pre = "fas fa-info-circle"
  6. identifier = "theme"
  7. [[menu.main]]
  8. weight = 1
  9. name = "About"
  10. url = "/pages/hugo-theme-w3css-basic/"
  11. pre = "fas fa-info fa-fw"
  12. parent = "theme"
  • Topbar: right aligned top menu (github, facebook, twitter, …)

  • Navbar “Small” with numOfItemsIfSmallDisplay = 2

screenshot numOfItemsIfSmallDisplay 2

  1. # right aligned
  2. [[menu.topbar]]
  3. weight = 1
  4. name = "GitHub"
  5. url = "https://github.com/it-gro/hugo-theme-w3css-basic"
  6. pre = "fab fa-github"
  • on small displays the root menu entries are truncated
    {{- substr (default .Name (i18n .Name)) 0 ($.Scratch.Get "smallDispMenuMaxChars") | lower}}

screenshot Marquee & Navbar small

  1. [params.menuConfig]
  2. # used in layouts/partials/header.nav.html
  3. # if set => change menu entry on small displays to lowercase maxChars
  4. smallDispMenuMaxChars = 2
  5. smallDispMenuCollapse = false
  6. smallDispMenuCollapseIcon = "fas fa-caret-square-down"
  7. [params.menuTopBar]
  8. # used in layouts/partials/header.nav.html
  9. # enable or disable menu.topbar with social icons (right aligned)
  10. socialEnable = true
  11. numOfItemsIfSmallDisplay = 0
  12. numOfItemsIfMediumDisplay = 3
  13. numOfItemsIfSmallDisplayCollapsed = 6
  14. # used in layouts/partials/header.nav.html
  15. # layouts/partials/header.nav.google.translate.html
  16. googleTranslateEnable = true
  17. googleTranslateShowOnHome= false
  18. themeColorSelectorEnable = false

Fonts

  1. [params]
  2. # used in layouts/partials/head.html
  3. # if fontsUseGoogleApis=true then choose your fonts in [params.googleApiFonts.family.*] (see below)
  4. fontsUseGoogleApis=false
  1. {{ partial "head.stylesheets.html" . -}}
  2. {{- if .Site.Params.fontsUseGoogleApis }}
  3. {{ partial "head.fonts.googleapis.html" . -}}
  4. {{- else }}
  5. {{ partial "head.fonts.local.html" . -}}
  6. {{- end }}

Choose any Font via googleapis

If you set fontsUseGoogleApis=true you can choose any font from
https://fonts.google.com

Hash Borgir had a cool idea: How To Dynamically Use Google Fonts In A Hugo
Website
.
I had the same goal. It’s all configured in the
config.toml
file.

Here’s the relevant part:

  1. [params.googleApiFonts.family]
  2. # https://www.w3.org/Style/Examples/007/fonts.en.html
  3. # the predefined generic font names are:
  4. # sans-serif = ""
  5. # serif = ""
  6. # monospace = ""
  7. # cursive = ""
  8. # fantasy = ""
  9. # used in static/vendor/w3css/4/w3.css
  10. # code,kbd,pre,samp : monospace
  11. # html,body : sans-serif
  12. # h1 : serif
  13. # h1,h2,h3,h4,h5,h6 : sans-serif
  14. # .w3-code,.w3-codespan : Consolas,"courier new"
  15. # https://www.w3schools.com/tags/ref_byfunc.asp
  16. # tagsText = [ "html", "body" ]
  17. tagsText = [ "html", "body", "abbr", "address", "blockquote", "cite", "dfn", "em", "ins", "mark", "s", "time" ]
  18. tagsHeading = [ "h1", "h2", "h3", "h4", "h5", "h6" ]
  19. tagsMono = [ "pre", "code", "kbd", "samp" ]
  20. # these parameter sections must exist, the others are optional
  21. fallbackText = "html"
  22. fallbackHeading = "h1"
  23. fallbackMono = "pre"
  24. [params.googleApiFonts.family.html]
  25. # serif, sans-serif or even cursive
  26. sans-serif = "Oswald"
  27. [params.googleApiFonts.family.h1]
  28. # serif, sans-serif or even cursive
  29. sans-serif = "Creepster"
  30. [params.googleApiFonts.family.pre]
  31. # monospace or sans-serif
  32. monospace = "Space Mono"
  33. [params.googleApiFonts.family.kbd]
  34. monospace = ""
  35. [params.googleApiFonts.family.samp]
  36. sans-serif = "Roboto"

This would lead to:

  1. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Oswald|Creepster|Space+Mono|Roboto" />
  2. <style> html {font-family: 'Oswald', sans-serif; } </style>
  3. <style> body {font-family: 'Oswald', sans-serif; } </style>
  4. <style> abbr {font-family: 'Oswald', sans-serif; } </style>
  5. <style> address {font-family: 'Oswald', sans-serif; } </style>
  6. <style> blockquote {font-family: 'Oswald', sans-serif; } </style>
  7. <style> cite {font-family: 'Oswald', sans-serif; } </style>
  8. <style> dfn {font-family: 'Oswald', sans-serif; } </style>
  9. <style> em {font-family: 'Oswald', sans-serif; } </style>
  10. <style> ins {font-family: 'Oswald', sans-serif; } </style>
  11. <style> mark {font-family: 'Oswald', sans-serif; } </style>
  12. <style> s {font-family: 'Oswald', sans-serif; } </style>
  13. <style> time {font-family: 'Oswald', sans-serif; } </style>
  14. <style> h1 {font-family: 'Creepster', sans-serif; } </style>
  15. <style> h2 {font-family: 'Creepster', sans-serif; } </style>
  16. <style> h3 {font-family: 'Creepster', sans-serif; } </style>
  17. <style> h4 {font-family: 'Creepster', sans-serif; } </style>
  18. <style> h5 {font-family: 'Creepster', sans-serif; } </style>
  19. <style> h6 {font-family: 'Creepster', sans-serif; } </style>
  20. <style> pre {font-family: 'Space Mono', monospace; } </style>
  21. <style> code {font-family: 'Space Mono', monospace; } </style>
  22. <style> kbd {} </style>
  23. <style> samp {font-family: 'Roboto', sans-serif; } </style>
  • Note how kbd is “blanked” and samp has it’s own style (just to give you the
    idea).

An other example would be:

  1. [params.googleApiFonts.family]
  2. tagsText = [ "html", "body", "time" ]
  3. tagsHeading = [ "h1", "h2", "h3", "h4", "h5", "h6" ]
  4. tagsMono = [ "pre", "code" ]
  5. fallbackText = "html"
  6. fallbackHeading = "h1"
  7. fallbackMono = "pre"
  8. [params.googleApiFonts.family.html]
  9. sans-serif = "Poppins"
  10. [params.googleApiFonts.family.time]
  11. cursive = "Creepster"
  12. [params.googleApiFonts.family.h1]
  13. sans-serif = "Days One"
  14. [params.googleApiFonts.family.pre]
  15. monospace = "Cousine"

gives:

  1. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins|Days+One|Cousine" />
  2. <style> html {font-family: 'Poppins', sans-serif; } </style>
  3. <style> body {font-family: 'Poppins', sans-serif; } </style>
  4. <style> time {font-family: 'Creepster', cursive; } </style>
  5. <style> h1 {font-family: 'Days One', sans-serif; } </style>
  6. <style> h2 {font-family: 'Days One', sans-serif; } </style>
  7. <style> h3 {font-family: 'Days One', sans-serif; } </style>
  8. <style> h4 {font-family: 'Days One', sans-serif; } </style>
  9. <style> h5 {font-family: 'Days One', sans-serif; } </style>
  10. <style> h6 {font-family: 'Days One', sans-serif; } </style>
  11. <style> pre {font-family: 'Cousine', monospace; } </style>
  12. <style> code {font-family: 'Cousine', monospace; } </style>

A short version (just 2 fonts) looks like this:

  1. tagsText = [ "html", "body" ]
  2. tagsHeading = [ "h1", "h2", "h3", "h4", "h5", "h6" ]
  3. tagsMono = [ "pre", "code" ]
  4. fallbackText = "html"
  5. fallbackHeading = "html"
  6. fallbackMono = "pre"
  7. [params.googleApiFonts.family.html]
  8. cursive = "Nova Slim"
  9. [params.googleApiFonts.family.pre]
  10. monospace = "Nova Mono"

gives:

  1. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nova+Slim|Nova+Mono" />
  2. <style> html {font-family: 'Nova Slim', cursive; } </style>
  3. <style> body {font-family: 'Nova Slim', cursive; } </style>
  4. <style> h1 {font-family: 'Nova Slim', cursive; } </style>
  5. <style> h2 {font-family: 'Nova Slim', cursive; } </style>
  6. <style> h3 {font-family: 'Nova Slim', cursive; } </style>
  7. <style> h4 {font-family: 'Nova Slim', cursive; } </style>
  8. <style> h5 {font-family: 'Nova Slim', cursive; } </style>
  9. <style> h6 {font-family: 'Nova Slim', cursive; } </style>
  10. <style> pre {font-family: 'Nova Mono', monospace; } </style>
  11. <style> code {font-family: 'Nova Mono', monospace; } </style>
  • You need to go to https://fonts.google.com/ (preview the fonts).
  • There is a usefull list: Popular Pairings with … under See Specimen
  • After selecting a Font click Family Selected. You see e.g.:

Use the following CSS rules to specify these families:
font-family: ‘Roboto’, sans-serif;

(Do not add the “+” or “|” signs in the api url - this is done in the partial)

Here is a random list of some fonts you may want to try to get the
impression. Copy them to the [params.googleApiFonts.family.*] sections.

  1. sans-serif = "Capriola"
  2. sans-serif = "Days One"
  3. sans-serif = "Open Sans"
  4. sans-serif = "Oswald"
  5. sans-serif = "Oxygen"
  6. sans-serif = "Paytone One"
  7. sans-serif = "Poppins"
  8. sans-serif = "Quantico"
  9. sans-serif = "Raleway"
  10. sans-serif = "Roboto"
  11. sans-serif = "Ubuntu"
  12. serif = "Gabriela"
  13. serif = "Glegoo"
  14. serif = "Noticia Text"
  15. serif = "Roboto Slab"
  16. monospace = "Cousine"
  17. monospace = "Oxygen Mono"
  18. monospace = "Roboto Mono"
  19. monospace = "Space Mono"
  20. monospace = "Ubuntu Mono"
  21. cursive = "Caesar Dressing"
  22. cursive = "Carter One"
  23. cursive = "Courgette"
  24. cursive = "Creepster"
  25. cursive = "Parisienne"
  26. cursive = "Patrick Hand"
  27. cursive = "Rammetto One"
  28. cursive = "Rochester"
  29. cursive = "Romanesco"

Contact Map

  1. [params]
  2. # Google Maps API key
  3. # get our own: https://developers.google.com/maps/documentation/javascript/adding-a-google-map#key
  4. # used in layouts/partials/contact.map.html
  5. # if empty => fallback to URL (instead of map)
  6. # define environment variable (=> key is not stored in github)
  7. envGoogleMapsApiKey = "GoogleMapsApiKey"
  8. # if environment is not an option => define key here:
  9. #googleMapsApiKey = ""
  10. #googleMapsZoom = 14
  11. googleMapsZoom = 3
  12. latitude = 46.946692
  13. longitude = 7.444186

Here’s how to use the environment variable:

  1. $ export GoogleMapsApiKey=GEeawyBOuzOPzbFGizHKGReghibngUZTGjlioZM
  2. $ hugo
  • Contact form with map

screenshot Contact

  • Contact form with disabled Javascript

screenshot Contact no JavaScript

  • if no latitude or longitude is given, no map is shown

Google Translation

screenshot Google Translate

  1. [params.menuTopBar]
  2. googleTranslateEnable = true
  3. googleTranslateShowOnHome= false
  • the google translate widget is not shown:
    • on small displays
    • on the home page - if googleTranslateShowOnHome is set to false
      (Google PageSpeed complains, Google bot gets confused)
  • set googleTranslateEnable to false in order to disable google translate globaly

layouts/partials/header.nav.html

  1. <div class="w3-bar w3-hide-small ... ">
  2. {{- if .Site.Params.menutopbar.googleTranslateEnable }}
  3. {{- if or (not .IsHome) .Site.Params.menutopbar.googleTranslateShowOnHome }}
  4. <span class="w3-bar-item w3-button w3-right">
  5. {{ partial "header.nav.google.translate.html" . -}}
  6. </span>
  7. {{- end }}
  8. {{- end }}

screenshot Google Translate

No translation is done for

  • About and Adress in footer (class=”notranslate”)

layouts/partials/footer.html

  1. <div class="w3-col w3-third">
  2. <h4>{{ default "About" (i18n "aboutUs") }}</h4>
  3. <div class="notranslate">{{- .Site.Params.aboutUs | markdownify }}</div>
  4. </div> <!-- w3-col -->
  • results of shortcode highlight (internal), w3-code, w3-codespan, cscb and csc
  • currently results of markdown backticks get translated, which is odd

screenshot Google Translate

Google Custom Search API

  1. # https://cse.google.com/cse/
  2. # used in layouts/partials/search.google.gcse.html
  3. googleCustomSearchCX = '002931815551392744433:tnypjyusk2e'
  • Used for search page /search which is linked into the toolbar menu here:
  1. [[menu.topbar]]
  2. weight = 5
  3. name = "Search"
  4. url = "/search"
  5. pre = "fas fa-search"
  • Search form

screenshot Search

  • Search form with disabled Javascript

screenshot Search no JavaScript

Google Analytics-Tracking using gtag

  1. # Enable Google Analytics by entering your tracking code
  2. googleAnalytics = ""
  3. [params]
  4. # https://developers.google.com/gtagjs/
  5. # used in layouts/partials/head.google.gtags.html
  6. # you need to enter the Tracking-ID above
  7. enableGoogleGtag=true
  • Firefox has a Tracking Protection which
    prevents gtag.js tracking by default.
  • gtag.js is not used if enableGoogleGtag is not set to true or the tracking code is not given (googleAnalytics)
  1. {{- if and $.Site.Params.enableGooglesGtag $.Site.Config.Services.GoogleAnalytics.ID }}
  2. {{- /* <!-- Global site tag (gtag.js) - Google Analytics --> */}}
  3. <script async src="https://www.googletagmanager.com/gtag/js?id={{$.Site.Config.Services.GoogleAnalytics.ID}}"></script>
  1. # used in layouts/partials/footer.html
  2. # uses markdownify
  3. aboutUs = '''
  4. ....
  5. '''
  6. address = '''
  7. ....
  8. '''
  9. # used in layouts/partials/footer.bottom.html
  10. bottomLeft = "Copyright (c) 2018, *lobortis nisl* ut aliquip ex ea commodo consequat"
  11. bottomRight = 'created with [Hugo](https://gohugo.io) '

screenshot Footer

cookieconsent

  1. static/vendor/insites/
  2. └── cookieconsent
  3. ├── cookieconsent.3.0.6.min.css
  4. └── cookieconsent.3.0.6.min.js

i18n/en.yaml

  1. # Cookie consent
  2. - id: cookieMessage
  3. translation: This website uses cookies to ensure you get the best experience on our website.
  4. - id: cookieDismiss
  5. translation: Got it!
  6. - id: cookieLearn
  7. translation: Learn more

config.toml

  1. [params.cookieconsent]
  2. # https://cookieconsent.insites.com/download/
  3. # used in layouts/partials/head.cookieconsent.html
  4. enable = true
  5. popupBackground = "#efefef"
  6. popupText = "#404040"
  7. buttonBackground = "#8ec760"
  8. buttonText = "#ffffff"
  9. #static = "true"
  10. position = "bottom"
  11. #position = "top"
  12. #position = "bottom-left"
  13. #position = "bottom-right"
  14. #position = "top-left"
  15. #position = "top-right"
  16. theme = "classic"
  17. #theme = "edgeless"
  18. #theme = ""
  19. href = "https://cookiesandyou.com"

screenshot cookieconsent

screenshot cookieconsent

RSS

  1. # RSS Feed
  2. # Do not build RSS files
  3. disableRSS = false
  4. # maximum number of items in the RSS feed
  5. rssLimit = 10

Tracing

  • If you like comments in the html source, this one is for you
  1. # flags used for tracing and html comment output
  2. # currently used:
  3. # html-comment enable partials html comment output
  4. # debug-shortcodes enable all shortcodes debugging output
  5. # debug-shortcode-liti enable all shortcode liti debugging output
  6. # traceFlags = "html-comment:debug-shortcode-liti"
  7. traceFlags = "html-comment"

If traceFlags includes the word html-comment some HTML comments will
be included in the html source code.

Custom CSS and JS

  • This theme comes with the following “empty” files
  1. static/
  2. ├── css
  3. ├── custom.css
  4. ├── js
  5. ├── custom.bottom.js
  6. ├── custom.top.js
  1. custom_css = [ "css/custom_foo.css", "https://cdnjs.cloudflare.com/ajax/libs/minireset.css/0.0.2/minireset.min.css" ]
  2. custom_js_top = [ "js/custom_top_bar.js" ]
  3. custom_js_bottom = [ "js/custom_bottom_foo.js", "https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js" ]
  1. [params]
  2. # used in layouts/partials/head.stylesheets.html
  3. # used in layouts/partials/scripts.bottom.html
  4. # used in layouts/partials/scripts.top.html
  5. custom_css = [ ]
  6. custom_js_top = [ ]
  7. custom_js_bottom = [ ]

Front Matter

archetypes:

  1. blog.md
  2. pages.md

Pages, Blogs

  1. ---
  2. title: "{{ replace .TranslationBaseName "-" " " | title }}"
  3. date: {{ .Date }}
  4. toc: false
  5. icon: "fab fa-font-awesome"
  6. resImgTeaser: "teaser.png"
  7. #resImgCmd:
  8. #resImgOpt:
  9. description: >
  10. I'm an **example** description.
  11. I'll show in teaser instead of (calculated) summary.
  12. tags:
  13. - "example tag 1"
  14. - "example tag 2"
  15. categories:
  16. - "example cat 1"
  17. - "example cat 2"
  18. ---
  • for pages add:
  1. weight: 42

content/pages/*/_index.md

  1. ---
  2. weight: 24
  3. title: "My **Stuff** :house:"
  4. date: 2017-11-13T15:37:04+01:00
  5. resImgTeaser: teaserpics/gohugo.io/golang-a-closer-look.png
  6. icon: "fas fa-list"
  7. ---
  • this defines how the page navigation entries look like. See Pages Navigation for more.

Shortcodes

  1. layouts/shortcodes/
  2. ├── alert.html
  3. ├── asciicast.html
  4. ├── classify.html
  5. ├── csc.html
  6. ├── cscb.html
  7. ├── hc.html
  8. ├── heg-figure.html
  9. ├── heg-gallery.html
  10. ├── heg-load-photoswipe.html
  11. ├── html-tag-classes.html
  12. ├── html-tag.html
  13. ├── html-tags.html
  14. ├── i18n.html
  15. ├── icon.html
  16. ├── kbd.html
  17. ├── liti.html
  18. ├── litt.html
  19. ├── litx.html
  20. ├── readfile.html
  21. ├── res-attach.html
  22. ├── res-debug.html
  23. ├── res-figure.html
  24. ├── res-gallery.html
  25. ├── res-gallery-load-photoswipe.html
  26. ├── w3-alert-icon.html
  27. ├── w3-badge.html
  28. ├── w3-button-icon.html
  29. ├── w3-code.html
  30. ├── w3-codespan.html
  31. ├── w3-notice-icon.html
  32. ├── w3-quote.html
  33. └── w3-tag.html

Page Resources

Headless Images

  • images may be stored as resource for a headless page:
  • those images may be used for
    • teaserpics (resImgTeaser)
    • figures (res-figure)
    • gallery (res-gallery)
    • pictures for jumbotron, photocards, testimonials
  • the path for the default (global) headless page is configurable

config.toml

  1. [params.resources]
  2. defaultResPagePath = "resources/images"
  3. [params.resFigure]
  4. defaultResPagePath = "."
  5. [params.resGallery]
  6. defaultResPagePath = "resources/images"

content/resources/images/index.md

  1. ---
  2. title: "headless-images"
  3. headless: true
  4. ---
  1. content/resources/images/
  2. ├── clients
  3. └── pixabay.com
  4. ├── favicons
  5. ├── jumbotrons
  6. └── pixabay.com
  7. ├── photocards
  8. └── pixabay.com
  9. ├── teaserpics
  10. ├── bitbucket.org
  11. ├── gohugo.io
  12. ├── pixabay.com
  13. └── wikipedia.org
  14. └── testimonials
  15. └── pixabay.com
  • A new headless page with the resources may be given in front matter via
    resImgRelPath
  1. ---
  2. resImgRelPath: "../img/"
  3. resImgTeaser: "dwh-1.jpg"
  4. ---
  • And of course the page itself may have the image resources (which overrides an
    image with the same name on the default (global) headless page)

Given a front matter

  1. resImgTeaser: teaserpics/pixabay.com/paint-2985569_640.jpg

The images is processed using hugo’s build in image commands (resize to a reasonable size).

layouts/partials/main.teaserpic.single.html

  1. {{- $myImgStyle := "max-width:400px; max-height:200px; width: auto; height: auto; margin: 8px 0px 8px 8px; " }}
  2. {{- $myImg := .Param `resImgTeaser` }}
  3. {{- $myImgCmd := .Param `resImgTeaserCmd` | default `Resize` }}
  4. {{- $myImgOpt := .Param `resImgTeaserOpt` | default `300x` }}

Images

screenshot Image Showcase

Attachments

screenshot Attachments

Include Files

  1. {{</* readfile "content/." */>}}

=>

  1. content/.
  2. Lrwxrwxrwx 2018-04-06 15 README.md
  3. drwxrwxr-x 2018-04-06 blog
  4. -rw-rw-r-- 2018-04-13 972 contact.md
  5. -rw-rw-r-- 2018-04-13 5407 faq.md
  6. drwxrwxr-x 2018-04-13 pages
  7. -rw-rw-r-- 2018-04-13 190 search.md
  1. {{</* readfile file="content/README.md" md="true" */>}}

=> include a markdownified markdown file

screenshot res-gallery

screenshot Gallery

content/pages/showcase/gallery-01.md

  1. ---
  2. title: "Gallery pixabay.com"
  3. date: 2018-01-05T20:30:54+01:00
  4. resImgTeaser: teaserpics/pixabay.com/paint-2985569_640.jpg
  5. icon: "fas fa-images"
  6. description: "Pictures from pixabay.com"
  7. tags:
  8. - Showcase
  9. categories:
  10. - This Theme
  11. ---
  12. {{< heg-load-photoswipe >}}
  13. {{< heg-gallery dir="/images/photocards/pixabay.com" caption-effect="none" hover-effect="grow" />}}
  • This themes version of {{</* heg-gallery .. */>}} improves the caption’s configuration (filename):
    • show file extensions - or not
    • do humanize - or not
    • the values below are the defaults:
  1. [params.gallery]
  2. # used in layouts/shortcodes/heg-gallery.html
  3. # showFileExtension = true
  4. # humanizeCaption = false

Figure

Figure with image processing

  1. {{< heg-load-photoswipe >}}
  2. {{< heg-figure link="/images/photocards/pixabay.com/04-photocard.jpg" caption-position="bottom" caption-effect="none" width="640px" caption="figure caption 4" attr="(c) by bar 4" attrlink="https://www.example.com" >}}
  • This themes version of {{</* heg-figure .. */>}} improves the
    usage of title caption attr attrlink which are all optional
  1. caption="figure caption 4" attr="(c) by bar 4" attrlink="https://www.example.com"
  • Shown on page

screenshot Figure

  • Shown with PhotoSwipe

screenshot Figure

Showcase

Usage

To see the exampleSite use:

  1. $ cd exampleSite/
  2. $ export GoogleMapsApiKey=GEeawyBOuzOPzbFGizHKGReghibngUZTGjlioZM
  3. $ hugo server -w --disableFastRender --navigateToChanged --themesDir ../../

Now enter localhost:1313 in the address bar of your browser.

For more information check out the official Hugo documentation.

Minifier

If you change the theme w3css-basic.min.css, syntax.min.css or
front.js, you have to apply a minifier. E.g.:

  1. cd themes/hugo-theme-w3css-basic/static/css
  2. yui-compressor --verbose --type css --line-break 1023 w3css-basic.css -o w3css-basic.min.css
  3. yui-compressor --verbose --type css --line-break 1023 syntax.css -o syntax.min.css
  4. cd -
  5. cd themes/hugo-theme-w3css-basic/static/js
  6. yui-compressor --verbose --type js --line-break 1023 --nomunge --preserve-semi front.js -o front.min.js
  7. cd -

or change the file names in
layouts/partials/head.stylesheets.html and layouts/partials/scripts.html

Workarounds

summaryLength

  • summaryLength was not configurable until hugo version 0.30
  • teaserTruncateSummary was my workaround. But I think it still make
    sense since summaryLength is in words and teaserTruncateSummary is in
    characters.
  • see Summary

Shortcode output wrapped in

hugo/issues/1642: Shortcode output wrapped in

tags

layouts/_default/baseof.html

  1. {{ .Content | replaceRE `(?s:</div>\s?</p>)` `</div>` | replaceRE `(?s:</pre>\s?</p>)` `</pre>` | replaceRE `(?s:</figure>\s*</p>)` `</figure>` | safeHTML }}

See https://discourse.gohugo.io/t/shortcodes-and-p-tags-2/9987

Tracking

Beeing able to analyse the visitors behavior via the log files on the visited site is one thing.
But giving those informations to any third-party is not what the visitors expect by default.

  • Why should a third-party (disqus.com) know which blog articles I’ve read (even without commenting) ?
  • Why should a third-party (formspree.io) beeing able to read the visitors messages (contact form) ?

If the visitors implicitly agree by clicking on a button (“see
comments on disqus.com” or “send message via formspree.io”) then this
is perfecly fine (for me).

This is also why I tried to minimize the external url’s and copied all
into the theme (static/vendor/*).

How to minimize visitors exposure to tracking

  • disable google gtags (analytics)
  • disable google translate
  • disable google fonts apis
  • disable google maps
  • disable menu.topbar search (google custom search)
  • disable formspree (but keep your email)
  • do not show a comment counter on the Disqus Button
  • review result e.g. with Firefox Lightbeam by Mozilla

All of the above is done in config.toml

  1. googleAnalytics = ""
  2. #[[menu.topbar]]
  3. # weight = 5
  4. # name = "Search"
  5. # url = "/search"
  6. # pre = "fas fa-search"
  7. [params]
  8. fontsUseGoogleApis = false
  9. # latitude =
  10. # longitude =
  11. formspree = ""
  12. email = "info@example.com"
  13. disqusButtonShowCount = false
  14. [params.menuTopBar]
  15. googleTranslateEnable = false

ToDo’s

Contributing

Did you found a bug or got an idea for a new feature? Feel free to use
the issue
tracker
to
let us know. Or make directly a pull
request
.

License

This theme is released under the MIT License.

Thanks

Thanks to:

More Screenshots

  • 1500x1000

screenshot 1500x1000

  • 900x600

screenshot thumbnail 900x600

screenshot thumbnail 900x600

screenshot thumbnail 900x600

screenshot thumbnail 900x600

screenshot thumbnail 900x600

screenshot thumbnail 900x600

screenshot thumbnail 900x600

screenshot thumbnail 900x600

  • Complete

screenshot complete