Closed Jammooka closed 10 years ago
I don't have problem you describe on my sites. In page I use standard markdown and put anchors like this:
[Installing](#installing) | [Content](#yourcontent)
## Installing {#installing}
## Content {#yourcontent}
Seems to work. Hover the links below.
Interesting. Your site works as expected. Is there anything on yours different from the default install?
For example, if I try it on ohdoylerules.com I get the following:
My site is actually an older install. I should try updating and seeing if that fixes anything
On Tuesday, March 11, 2014, Jamie Blacker notifications@github.com wrote:
Interesting. Your site works as expected. Is there anything on yours different from the default install?
For example, if I try it on ohdoylerules.com I get the following:
[image: image]https://f.cloud.github.com/assets/2698928/2384553/b61b0686-a90e-11e3-8f2b-2b4a0c5a939b.png
Reply to this email directly or view it on GitHubhttps://github.com/PhileCMS/Phile/issues/59#issuecomment-37285013 .
James Doyle
t: @james2doyle https://twitter.com/james2doylew: ohdoylerules.com http://ohdoylerules.com
Sussed it. It's down to the base tag, which your(jacmgr) site doesn't seem to have.
I don't fully understand the whys and wherefores of the base tag, it seems to work fine without. Pretty decent answer about it here: http://stackoverflow.com/questions/1889076/is-it-recommended-to-use-the-base-html-tag#answer-1889957
Either way, I've just removed the base tag from mine and it's now working.
A quick fix for now would be to use {{ current_page.url }}#anchor
On Tuesday, March 11, 2014, James Doyle james2doyle@gmail.com wrote:
My site is actually an older install. I should try updating and seeing if that fixes anything
On Tuesday, March 11, 2014, Jamie Blacker notifications@github.com<javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:
Interesting. Your site works as expected. Is there anything on yours different from the default install?
For example, if I try it on ohdoylerules.com I get the following:
[image: image]https://f.cloud.github.com/assets/2698928/2384553/b61b0686-a90e-11e3-8f2b-2b4a0c5a939b.png
Reply to this email directly or view it on GitHubhttps://github.com/PhileCMS/Phile/issues/59#issuecomment-37285013 .
James Doyle
t: @james2doyle https://twitter.com/james2doyle w: ohdoylerules.com http://ohdoylerules.com
James Doyle
t: @james2doyle https://twitter.com/james2doylew: ohdoylerules.com http://ohdoylerules.com
I'll see how it goes without the base tag. Do we know if there's any reason to include it?
You're correct my site is not using the <base href="{{base_url}}/" />
in the templates. I forgot about that. I removed it, because I had problems in general with relative links in markdown content. Didn't realize was related to this symptom! However, I had to add in a lot of {{ base_url }}
in my templates to compensate. I'd rather use the base tag, but what I got is working for me.
Stuff like this
<a class="brand" href="{{ base_url }}">{{ site_title }}</a>
and
<li><a href="{{ base_url }}/{{ page.url }}">{{ page.title }}</a></li>
Alright that's good.
So to clarify, with the base meta tag the hash links don't work?
On Tuesday, March 11, 2014, jacmgr notifications@github.com wrote:
You're correct my site is not using the
in the templates. I forgot about that. I removed it, because I had problems in general with relative links in markdown content. Didn't realize was related to this symptom! However, I had to add in a lot of {{ base_url }} in my templates to compensate. I'd rather use the base tag, but what I got is working for me. Stuff like this {{ site_title }} and
{{ page.title }} Reply to this email directly or view it on GitHubhttps://github.com/PhileCMS/Phile/issues/59#issuecomment-37288606 .
James Doyle
t: @james2doyle https://twitter.com/james2doylew: ohdoylerules.com http://ohdoylerules.com
That's correct. As far as I can tell, the base tag makes all links relative to the root rather than the current page. If you remove it, then you just need to use a forward slash to make them relative to the root.
{% for page in pages %}
<li{% if current_page.title == page.title %} class="active"{% endif %}>
<a href="/{{ page.url }}">
{{ page.title }}
</a>
</li>
{% endfor %}
Works fine for me.
That said, I've changed my Page model to remove index so it might work slightly differently. Don't think it will though, I just added in
$pathFragments = explode('/', $this->url);
if(end($pathFragments) == 'index') {
array_pop($pathFragments);
$this->url = implode('/', $pathFragments);
}
Hey, @james2doyle ! it's lead to #53 and it actually the same as I've found in this PR.
We should just use correct url for base
tag. The URL for current page.
If we use <base href="{{base_url}}/" />
, it will refer to the root from all pages.
So, the better way is <base href="{{ base_url }}{{ current_page.url }}" />
and all should be fine (I tried to push PR here)... but not, because of bug (#53) =)
I'm not sure that is the correct URL though. I could be wrong, but I think the base URL is supposed to be set to the root.
The <base> tag specifies the base URL/target for all relative URLs in a document.
hmm, ok, my fault, it should be set for root.. but: anchors will be also calculated from root in this case :D
<base href="{{ base_url }}/{{ current_page.url }}" />
would not be a good idea. This code means, "all links on this page are relative to this page". With this code, once you go to a sub page, then your nav gets messed up.
Also when writing links in markdown, you can write [home](index)
and everything is fine. You don't need the base URL.
Right now the resolution to this issue is leaving the default base tag, then using {{ current_page.url }}#id-of-div
for any hash links.
Wouldn't {{ current_page.url }}#id-of-div cause a page reload?
I'm going to roll with no base tag and just set all my relative links to have a forward slash. Seems to be working so far!
or, you can don't use base
tag at all, and link just like [resources](#resources)
I just tested it on my site and it seemed to work without reloading the page.
Just tested, definitely doesn't cause a reload. I'm going to stick to no base tag, but I think that's this issue solved. Feel free to close if you guys are happy.
Ok well I think we all learned something about the base tag this week, it can be awesome and terrible.
Say you're on a page example.com/folder/page and you link to #test-id. Instead of scrolling to the top of test-id as expected, it points to example.com/#test-id
I can't for the life of me work out why this is. I thought it might just be something up with my install, but I've just been to http://ohdoylerules.com/personal-project/vim-svg and changed a random link in dev tools to point to #disqus_thread and it goes straight to http://ohdoylerules.com/#disqus_thread