{{ ASSET_PATH }} only seems to work in _includes/theme/themename/default.html, leaves off theme name in post.html and page.html #113

Closed
imjared opened this Issue Nov 21, 2012 · 11 comments

Projects

None yet

8 participants

@imjared
imjared commented Nov 21, 2012

To reproduce:

  • rake theme:switch name="twitter"
  • add an image (foo.jpg) asset to assets/themes/twitter/
  • modify _includes/themes/twitter/page.html to include the image path using the liquid variable {{ ASSET_PATH }}:
<div class="page-header">
  <h1>{{ page.title }} {% if page.tagline %} <small>{{ page.tagline }}</small>{% endif %}</h1>
  <img src="{{ ASSET_PATH }}/foo.jpg">
</div>

<div class="row">
  <div class="span12">
    {{ content }}
  </div>
</div>
  • modify _includes/themes/twitter/default.html to include foo.jpg
  <body>

  <img src="{{ ASSET_PATH }}/media_markHenning.jpg">
    <div class="navbar">
      <div class="navbar-inner">
        <div class="container">
          <a class="brand" href="{{ HOME_PATH }}">{{ site.title }}</a>
          <ul class="nav">

Expected Result

  • foo.jpg appears above the nav bar (from default.html template) as well as under the H1

Actual Result

  • foo.jpg appears above the nav bar (from default.html template) but shows as a broken image under the H1. screenshot. The image tag is rendered as <img src="/assets/themes//foo.jpg">, missing the theme directory.

I can reproduce this issue on includes/themes/[any theme]/page.html and includes/themes/[any theme]/post.html.

If I manually set asset_path in _config.yml, it behaves as expected.

@travisterwilligar

Same issue for me. Thanks for pointing out your workaround!

@travisterwilligar

Actually - here's how to do it. The default template explicitly declares the theme in the YAML front matter as:

theme :
name : design-co

Include that in your layout and you should be golden.

@daithi-coombes

I am having the same issue. I've placed a png in:

assets/themes/my-theme/images/foo.png

but {{ ASSET_PATH }} only prints out: `assets/themes//images/foo.png

I have the YAML front matter in the theme, I'm hoping to make my theme public so manually declaring the theme asset location in the _config.yml is not an option

@daithi-coombes

the issue appears to be in _includes/JB/setup

The var page.theme.name is empty, so the ASSET_PATH is not getting set with the theme name

@intco
intco commented Aug 31, 2013

+1

@LukasKnuth
Contributor

Still an issue... Just as @daithi-coombes described it.

@fujii
fujii commented Feb 20, 2014

I created a patch.
fujii/jekyll-bootstrap@16e8a9d

@leomperes

+1

@groundh0g
Collaborator

Housekeeping. I'll review the comment stream and @fujii's tweak. Will create PR after review / testing.

@groundh0g groundh0g self-assigned this Feb 28, 2015
@groundh0g
Collaborator

OK. Discussion time. The fix from @fujii works as expected. There's one snag, though. And I don't think it's a show-stopper. Somewhat related to #227, but barely.

There's an issue with variable scope and ASSET_PATH. The fix will allow the themes to access assets using the variable, but actual posts, drafts, and pages won't have a valid ASSET_PATH. And I'm not 100% convinced that they need it.

Happy Path (for templates):

jb-setup-happy-path

Gray Area (for posts, pages, and drafts):

jb-setup-ruhoh-path

If that's not an issue for you guys, I'm fine with just sticking a footnote somewhere that says that ASSET_PATH is only valid for themes. Pages, posts, and drafts are on their own.

@groundh0g groundh0g added this to the v 0.4.0 milestone Mar 15, 2015
@groundh0g
Collaborator

Tested without issue. No activity on comments. Merged.

@groundh0g groundh0g closed this Mar 15, 2015
@daveyarwood daveyarwood added a commit to daveyarwood/daveyarwood.github.io that referenced this issue Feb 12, 2016
@daveyarwood daveyarwood let's try this 5530a9f
@mrpippy mrpippy added a commit to bslabs/bslabs.github.io that referenced this issue Feb 29, 2016
@mrpippy mrpippy Fix ASSET_PATH for post pages on Jekyll 3.0
Post pages were broken with Jekyll 3.0, fix this by applying
this patch:
plusjade/jekyll-bootstrap@c3d3cbe

issues:
plusjade/jekyll-bootstrap#113
plusjade/jekyll-bootstrap#290
d085150
@dannystaple dannystaple added a commit to odmsolutions/odmsolutions.github.io that referenced this issue Mar 25, 2016
@dannystaple dannystaple Try workaround d52dbf2
@btgoodwin btgoodwin added a commit to Geontech/rest-python that referenced this issue Apr 15, 2016
@btgoodwin btgoodwin Update _config.yml
Workaround for known bug plusjade/jekyll-bootstrap#113
b046da4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment