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

{{ 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
Assignees
Labels
Milestone

Comments

@imjared
Copy link

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
Copy link

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

@travisterwilligar
Copy link

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
Copy link

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
Copy link

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
Copy link

intco commented Aug 31, 2013

+1

@LukasKnuth
Copy link
Contributor

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

@fujii
Copy link

fujii commented Feb 20, 2014

@leompeters
Copy link

+1

@groundh0g
Copy link
Collaborator

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

@groundh0g
Copy link
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 added a commit that referenced this issue Mar 15, 2015
Tested without issue. No activity on #113 comments. Merging.
@groundh0g
Copy link
Collaborator

Tested without issue. No activity on comments. Merged.

daveyarwood added a commit to daveyarwood/blog.djy.io that referenced this issue Feb 12, 2016
mrpippy added a commit to bslabs/bslabs.github.io that referenced this issue Feb 29, 2016
dannystaple added a commit to odmsolutions/odmsolutions.github.io that referenced this issue Mar 25, 2016
btgoodwin added a commit to Geontech/rest-python that referenced this issue Apr 15, 2016
aterai pushed a commit to aterai/jekyll-bootstrap that referenced this issue Mar 11, 2019
noseka1 added a commit to noseka1/linuxband that referenced this issue Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants