middleman: `set :http_prefix` is not working in the build configuration block
It seems that
configure :build do
set :http_prefix, "/someprefix"
end
is not working properly on rc.1. If you try to use
set :http_prefix, "/someprefix"
outside the configure block it seems to work.
Thank you. Vincenzo
About this issue
- Original URL
- State: closed
- Created 12 years ago
- Comments: 27 (16 by maintainers)
Commits related to this issue
- Make :http_prefix work in link_to and asset helpers as long as the linked item is a sitemap resource. Fixes #484. — committed to bhollis/middleman by bhollis 12 years ago
I’m confused as to what the decision was, and how to trigger the feature, and which version it’s available in.
I’m hosting on github pages, so I want to use
link_toeverywhere, and set thehttp_prefixin the build config such that when I upload to github pages, all the links work. Later, if I build for s3 or something else, I expect to be able to replace the http_prefix or similar attribute and have all the links and assets prefixed. Right now I can’t seem to find a combination that works as expected and works in live preview mode.I will try to boil it down to a minimal example, but I tried a bunch of techniques here: http://bewest.github.io/glucose-html5/wiki/Home/ and couldn’t get
link_toto produce links that will work on gh-pages and in live preview mode in such a way that I can easily change it later. I see some deploy plugins, but it’s seems they mainly handle authorization logic around uploading.Say you have a 3 languages static site and you want to put it under a web server.
Without any
http_prefixsetting you have the following scenario:The root address is
/and the language under/is eng. You have italian under/it/and spanish under/es/.Now let’s say you need to put your whole static site in a subfolder, let’s say
/new/.In this situation, all the localized pages links will not work, as they need to refer to a “relative to root” structure. If you are viewing
/new/it/ciao.htmland you want to access to/new/hello.htmlor/new/es/hola.htmlyou can’t, since if you are viewing the italian version under/new/it/, the relative links will behello.htmlresolving to/new/it/hello.html(404) ores/hola.htmlresolving to/new/it/es/hola.html(same 404).This is a problem I encountered in my last project (you can watch at my
mdrepository in my Github account).set :http_prefixcould elegantly solve this little issue, and I think that prepending something to all the URL is less ambiguous than the actual behaviour.I think that it should prepend a prefix to all urls, in this way you can easily put a compiled static site into any subdirectory. It is very handy if you want to mantain your urls relative to the root, and you want the freedom of changing the place your static site lives in. Plus I think that adding a prefix to all urls is less ambiguous. For the cdn case, you should use the base tag and compile with relative assets.
I was setting in both cases to view the differences between the build code and the live code.
I noticed that the
:http_prefixis not added when you activate:relative_assets.However, if you use
:http_prefixwhile not activating:relative_assets, all the helpers likeimage_tag,stylesheet_link_tag,javascript_include_tag… works fine, but thelink_tomethod don’t work.I expect that
produces
but instead I get:
Notice that the
image_taghelper is working, but thelink_tois not.