Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Include <base> elements early in <head>
For use with troublesome /double//slashed paths and dynamic addresses.
  • Loading branch information
da2x committed Aug 1, 2015
1 parent 15217bc commit 465fa43
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -9,6 +9,7 @@ Features
Bugfixes
--------

* <base href> resolve common relative resource loading issues
* Handle non-integer shutter speeds and other variables in WordPress
importer (Issue #1917)

Expand Down
4 changes: 3 additions & 1 deletion nikola/data/themes/base-jinja/templates/base_helper.tmpl
Expand Up @@ -21,10 +21,12 @@ dir="rtl"
lang="{{ lang }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<base href="{{ abs_link(permalink) }}">

{% if description %}
<meta name="description" content="{{ description }}">
{% endif %}
<meta name="viewport" content="width=device-width">
<title>{{ title|e }} | {{ blog_title|e }}</title>

{{ html_stylesheets() }}
Expand Down
4 changes: 3 additions & 1 deletion nikola/data/themes/base/templates/base_helper.tmpl
Expand Up @@ -21,10 +21,12 @@ dir="rtl" \
lang="${lang}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<base href="{{ abs_link(permalink) }}">

%if description:
<meta name="description" content="${description}">
%endif
<meta name="viewport" content="width=device-width">
<title>${title|striphtml} | ${blog_title|striphtml}</title>

${html_stylesheets()}
Expand Down
Expand Up @@ -26,10 +26,12 @@ dir="rtl"
lang="{{ lang }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="{{ abs_link(permalink) }}">

{% if description %}
<meta name="description" content="{{ description }}">
{% endif %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title|e }} | {{ blog_title|e }}</title>

{{ html_stylesheets() }}
Expand Down
4 changes: 3 additions & 1 deletion nikola/data/themes/bootstrap3/templates/base_helper.tmpl
Expand Up @@ -26,10 +26,12 @@ dir="rtl" \
lang="${lang}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="{{ abs_link(permalink) }}">

%if description:
<meta name="description" content="${description}">
%endif
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${title|striphtml} | ${blog_title|striphtml}</title>

${html_stylesheets()}
Expand Down

7 comments on commit 465fa43

@Kwpolska
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

Please show me any website that uses it. They can also break anchors. Besides, we handle our own URL fixing pretty well.

I’m reverting those commits.

@da2x
Copy link
Contributor Author

@da2x da2x commented on 465fa43 Aug 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No!

@da2x
Copy link
Contributor Author

@da2x da2x commented on 465fa43 Aug 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added because of this,
https://chriswarrick.com/blog/2015//07/06/upass/

@da2x
Copy link
Contributor Author

@da2x da2x commented on 465fa43 Aug 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google Translated pages (from translate.google.com) only works because of this tag rewriting URLs from their original hosts without modifying the document.

@da2x
Copy link
Contributor Author

@da2x da2x commented on 465fa43 Aug 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you see broken anchors,, the anchors were already broken or too ambiguous.

@da2x
Copy link
Contributor Author

@da2x da2x commented on 465fa43 Aug 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out your own 404-pages:
https://chriswarrick.com/dsfs/sdff/ee///dfdf
https://chriswarrick.com/dsfs/sdff/ee/ (not even any double-slashes)

@da2x
Copy link
Contributor Author

@da2x da2x commented on 465fa43 Aug 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Nikola that uses relative URLs by default, the base tag is highly recommended. Sorting out all of this is the tag’s explicit purpose.

Please sign in to comment.