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

Enable usage of relative URLs for avatars #683

Closed
lcolladotor opened this Issue Sep 10, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@lcolladotor

lcolladotor commented Sep 10, 2018

Hi @gcushen,

Based on these 3 comments on the blogdown repo:

I believe that hugo-academic doesn't support relative URLs for the avatar. That is

<div class="portrait" style="background-image: url('{{ (printf "img/%s" $.Site.Params.avatar) | absURL }}');"></div>
<meta itemprop="image" content="{{ (printf "img/%s" $.Site.Params.avatar) | absURL }}">
uses absURL in: {{ (printf "img/%s" $.Site.Params.avatar) | absURL }}'. Would changing this to {{ (printf "img/%s" $.Site.Params.avatar) | absURL | relURL }}' solve this? Or maybe changing to {{ (printf "img/%s" $.Site.Params.avatar) | relURL }}'? (I don't know the proper hugo syntax)

By the way, I currently see 9 results of absURL when searching the repo https://github.com/gcushen/hugo-academic/search?utf8=%E2%9C%93&q=absURL&type= that I guess could result in similar issues.

Best,
Leo

@lcolladotor

This comment has been minimized.

lcolladotor commented Sep 10, 2018

I know that if we change lines 13 and 14 to:

      <div class="portrait" style="background-image: url('./{{ (printf "img/%s" $.Site.Params.avatar) | absURL }}');"></div>
      <meta itemprop="image" content="{{ (printf "img/%s" $.Site.Params.avatar) | absURL }}">

screen shot 2018-09-10 at 10 31 59 am

then it works. That is, adding ./ before {{ on line 13 and basically forcing the URL to be relative. We (me and @ShanEllis) tried using relURL instead of absURL, but we saw that it wasn't defined when we deleted (printf "img/%s" $.Site.Params.avatar) |. It would lead to an error like this:

error calling partial: template: partials/widgets/about.html:13:62: executing "partials/widgets/about.html" at <relURL>: wrong number of args for relURL: want 1 got 0

I'm hoping you have a more elegant, stable and robust solution than the one we found so that no one has to edit the about.html file.

Thanks!

@gcushen

This comment has been minimized.

Owner

gcushen commented Sep 10, 2018

Hugo has known issues with relative URLs in style tags. We have tried to workaround it so that the about widget avatar works on most kinds of deployment by using absolute URLs. For example, the demo on the Hugo Themes Site doesn't work when the avatar image is a relative URL.

You mentioned that RStudio hosting doesn't support absolute URLs, but I believe this might cause issues in other aspects of your website such as SEO metadata and social sharing, where absolute URLs are required.

gcushen added a commit that referenced this issue Sep 15, 2018

gcushen added a commit that referenced this issue Sep 15, 2018

@gcushen

This comment has been minimized.

Owner

gcushen commented Sep 15, 2018

We have made some updates that might improve the deployment to your RStudio host. However, note that the bug in your host's capability to use absolute URLs may affect the features mentioned above which require absolute URLs in order to operate.

@gcushen gcushen closed this Sep 15, 2018

@lcolladotor

This comment has been minimized.

lcolladotor commented Sep 17, 2018

Awesome, thanks @gcushen!

Can you give it a try @ShanEllis?

ltiao added a commit to ltiao/hugo-academic that referenced this issue Oct 10, 2018

Merge remote-tracking branch 'upstream/master'
* upstream/master: (39 commits)
  Update Readme
  i18n: Update Chinese translation (gcushen#717)
  posts: Add featured image option and stream layout for widget
  Add experience widget
  shortcodes: Update figure and video to support files within page dir
  CSS: Prevent Hugo encoding Google Fonts and fix docs sidebar toggle bg
  docs layout: Fix responsiveness of sidebar over range of resolutions
  posts: Make using content template (e.g. hugo new) optional
  project widget: Make filter toolbar responsive
  Support custom site description and thumbnail image for SEO and sharing (gcushen#696)
  docs layout: Fix case where side nav links can overlap
  Revise table of contents for docs layout and top navbar
  Add slides feature
  about widget: Refactor avatar (gcushen#683)
  publication: Add optional DOI link (gcushen#677)
  JS: Fix Algolia template and refactor Hero
  Refactor most absolute URLs to relative URLs
  CSS: Fix Bootstrap 4 grid system for Safari
  docs layout: Support nested docs folders
  i18n: Add Catalan translation (gcushen#676)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment