-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add "edit this page" link #157
Conversation
This is a link to a preview of the website from this Pull Request: https://freifunk.dev/edit-git/. |
layouts/partials/footer.html
Outdated
<a class="px-2" href="{{ $Site.Params.editURL }}{{ replace .Dir "\\" "/" }}{{ .LogicalName }}" target="blank"> | ||
{{"Edit this page"}} | ||
</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the functionality, but we should not make this a <a href>
-link that could be discovered and followed by search engines. I propose that we mask this link e.g. by using a span with an onclick event and a data attribute:
<span class="px-2"
data-url="{{ $Site.Params.editURL }}{{ replace .Dir "\\" "/" }}{{ .LogicalName }}"
onclick="window.open(this.getAttribute('data-url'), '_blank');">
{{"Edit this page"}}
</span>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the onlick is dirts and might not work with opening in a new tab or with javascript deactivated.
Wouldn't a rel=”nofollow”
suffice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the onlick is dirts and might not work with opening in a new tab or with javascript deactivated.
Without JavaScript the Freifunk website does not fully work either (e.g. language switcher) and editing at GitHub also requires JavaScript. Without it the content and edit form is not even visible.
Wouldn't a rel=”nofollow” suffice?
The idea behind masking the link is to reduce the number of outgoing links and prevent PageRank from beeing assigned to those links so the remaining internal links will be stronger. nofollow
does not do that. With nofollow
there will still be PageRank assigned to the links but the PageRank will not be passed on to the target pages. Compared to masking the links nofollow
would therefore weaken the site.
We can however just use JavaScript to create the link so it will only become visible when it would also be usable:
<span id="edit-page-link" class="px-2"
data-url="{{ $Site.Params.editURL }}{{ replace .Dir "\\" "/" }}{{ .LogicalName }}">
</span>
<script>
document.addEventListener("DOMContentLoaded", function() {
var editLink = document.getElementById('edit-page-link');
if (editLink) {
var url = editLink.getAttribute('data-url');
editLink.innerText = "Edit this page";
editLink.onclick = function() {
window.open(url, '_blank');
};
}
});
</script>
This resolves #132