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

author.picture and params.coverImage from config.yml don't behave the same way #327

Closed
xenlo opened this issue Feb 12, 2019 · 1 comment
Closed
Assignees
Labels
breaking changes enhancement New feature or request
Milestone

Comments

@xenlo
Copy link
Contributor

xenlo commented Feb 12, 2019

Hi/Bonjour,

I'm new with Hugo, so I'm not sure that this is a bug. At least the theme configuration, didn't behave the way I expected.

Configuration

  • hugo-tranquilpeak-theme 0.4.4-BETA
  • hugo v0.37.1 linux/amd64

Actual behavior

Parameters author.picture and params.coverImage from config.yml don't behave the same way.

I put both picture and coverImage files into ~/HugoProject/static/images/theme/. After building my site, both jpeg files end well in ~/HugoProject/public/images/theme/. But the html generated give:

baseURL: "http://example.org/"
[...]
author:
[...]
    picture:  "/images/theme/logo.jpg"
params:
[...]
    coverImage:  "/images/theme/cover_01.jpg"
[...]

A workaround is possible but tweaking the path only for coverImage like this:

    coverImage:  "/theme/cover_01.jpg"

Expected behavior

Images/files that we put at the same static place, and that end under the same path once generated should be referenced the same way in the config file.

Steps to reproduce the behavior

  1. Create a fresh Huge project
  2. Add the tranquilpeak-theme in it,
  3. Copy you Avatar/logo picture and background picture in the same directory somewhere under /static
  4. Edit your config.yml/tml to set picture and params.coverImage to point to the corresponding file (both having the same path)
  5. Generate you static site
@xenlo xenlo changed the title picture and params.coverImage from config.yml don't behave the same way author.picture and params.coverImage from config.yml don't behave the same way Feb 12, 2019
@xenlo
Copy link
Contributor Author

xenlo commented Feb 12, 2019

I dig a bit. I found that in certain files like themes/tranquilpeak/layouts/partials/meta.html, .Params.coverImageand .Author.picture are used the same way though absURL filter.

xenlo@silver-screen:~/Scripts/hugolwenn$ grep ".Params.coverImage\|.Author.picture" -C5 themes/tranquilpeak/layouts/partials/meta.html

{{ with .Params.thumbnailImage }}
  <meta property="og:image" content="{{ . | absURL }}">
  <meta property="twitter:image" content="{{ . | absURL }}">
{{ end }}
{{ with .Params.coverImage }}
  <meta property="og:image" content="{{ . | absURL }}">
  <meta property="twitter:image" content="{{ . | absURL }}">
{{ end }}
{{ with .Params.gallery }}
  {{ range . }}
--
{{ end }}

{{ if .Scratch.Get "gravatarEmail" }}
  <meta property="og:image" content="https://www.gravatar.com/avatar/{{ (md5 (.Scratch.Get "gravatarEmail")) | urlize }}?s=640">
  <meta property="twitter:image" content="https://www.gravatar.com/avatar/{{ (md5 (.Scratch.Get "gravatarEmail")) | urlize }}?s=640">
{{ else if .Site.Author.picture }}
  <meta property="og:image" content="{{ .Site.Author.picture | absURL }}">
  <meta property="twitter:image" content="{{ .Site.Author.picture | absURL }}">
{{ end }}

Nevertheless, in themes/tranquilpeak/layouts/partials/cover.html it adds an imges/ if the coverImage don't contain a ://.

{{ with .Site.Params.coverImage }}
  {{ if (in . "://") }}
    {{ $cover := . }}
    <div id="cover" style="background-image:url('{{ $cover | absURL }}');"></div>
  {{ else }}
    {{ $cover := (printf "images/%s" .) }}
    <div id="cover" style="background-image:url('{{ $cover | absURL }}');"></div>
  {{ end }}
{{ end }}

@kakawait kakawait added breaking changes enhancement New feature or request labels Jul 2, 2019
@kakawait kakawait self-assigned this Jul 2, 2019
@kakawait kakawait added this to the 0.4.5-BETA milestone Jul 2, 2019
@kakawait kakawait closed this as completed Jul 5, 2019
soichisumi added a commit to soichisumi/hugo-tranquilpeak-theme that referenced this issue Feb 24, 2020
* upstream/master: (28 commits)
  Fix wrong mini requirement
  🔖 version 0.4.7-BETA
  Upgrade index.html to support changes from 0.57
  update generator theme version
  🔖 version 0.4.6-BETA
  Remove stupid previous cover Image fix
  Update showcase
  build
  🔖 version 0.4.5-BETA
  0.4.5-BETA changelog
  Remove search stuffs if algolia is not set
  Update changelog & breaking change
  Always fetch cover image from base path
  Update doc & requirement
  Add check on legacy file path
  Remove grunt from doc, prefer using npm
  Fix eslint error
  Update deps & fix build for latest node
  Update base code to fix hugo warnings
  Proposition to correct issue kakawait#327, align static image behavior Second attempt with the right account this time I hope
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants