first time jekyll user - confused about 'page links' - ruby

So I finally got a blog going on gh-pages branch in a github repository using jekyll, and the theme lanyon. I love it. But something still bothers me.
On pages, the 'link' at the top of the article seems to default to a url I haven't really specified. This is what the top of my [YYYY-MM-DD-NAME].md files looks like...
---
layout: post
title: Page Name Here
---
Now, it renders okay, but Page Name Here shows up at the top, and is clickable, but I cannot figure out where to set the base url that it goes to. As it renders now, it does ...
[site root]/[page full filename]
but it should be ...
[site root]/[repo name]/[page full filename]
And I'm not clear on which variable in _config.yml I need to set to make this work right. Any suggestions?

As you're using Jekyll Bootstrap a post url tag is like this :
{{ post.title }}

You could also work with creating a url variable in _config.yml
url: www.website.com
and then creating a layout for posts with.
{{ post.title }}

Related

Generated links broken in Hugo/Blogdown when publishing to domain with subfolder

I am trying to use Hugo Xmin to create a static site. My site will be hosted in the gh-pages of my repository, therefore the final URL will look like:
https://myuser.github.io/myrepo/
Note At my current stage, I haven't modified any file in the example site that comes along with the theme, so basically the site I am deploying is the same exact in the original repository.
Problem I
In my config.toml I have set:
baseurl = "https://myuser.github.io/myrepo/"
Because with baseurl = "/" my links to the static CSS files in the <head> were not working and the site looked messy. By specifying the base url, CSS is loaded fine, but then top bar links are broken because this is what is generated:
<li>
About
</li>
Why is the generated URL looking so odd? The repository name is duplicated.
Problem II
The theme example site, in /content/_index.Rmarkdown has a few links at the end:
You can also visit the list page of a single section, e.g., [posts](/post/), or [notes](/note/). See the [About](/about/) page for more info.
Those do not work in my case because the URL that is generated is:
posts
Which will redirect the user to: https://myuser.github.io/post/ which is wrong. Basically this theme does not work when the hosting domain has a subfolder. Or am I missing anything here?
Troubleshooting
By investigating a bit I can see the theme defines those links like the following:
<ul class="menu">
{{ range .Site.Menus.main }}
<li>{{ .Name }}</li>
{{ end }}
</ul>
Function relURL is taking what comes after the hostname ans spitting it twice in the generated URL :(
The behavior of relURL seems to have changed since a certain version of Hugo (I don't know which). Anyway, you can remove the leading slashes in those menu items, e.g., change
[[menu.main]]
name = "About"
url = "/about/"
to
[[menu.main]]
name = "About"
url = "about/"

EmberJs model output into an img tag in a handlebar template

I am trying to learn EmberJs, in conjuction with Laravel 4, to create a blog. Things have been going great, stuff hasn't been too difficult yet. But I got into a snag when trying to have a <img/> tag in one of my handlebar templates.
From my understanding to use info from a model in a template you use {{attribute_name}} and like magic, it's there! And so for my tag I was trying something like:
<img src="{{URL::asset('images/posts/')}}#{{id}}.#{{image_extension}}" }}" alt=""/>
Adding the url to images with Laravel and Blade, then on the template, just adding in those last little pieces to make the it all work. But I get this instead:
<img src="http://localhost/blog/images/posts<script id='metamorph-11-start' type='text/x-placeholder'></script>26<script id='metamorph-11-end' type='text/x-placeholder'></script>.<script id='metamorph-12-start' type='text/x-placeholder'></script>jpg<script id='metamorph-12-end' type='text/x-placeholder'></script>" alt="">
Obviously theres script tags in my src tag and this is causing some issues.
Now then, upon much research I discovered {{unbound attribute_name}} and came up with:
<img src="{{URL::asset('images/posts')}}/#{{unbound id}}.#{{unbound image_extension}}" alt=""/>
and while this works on the first blog post I click, it doesn't switch images when I switch posts. So is there a way to make this guy work? I'm running out of ideas! Any information you could shed on this would be great! I really like ember so far and want to get even better! IF there's any more info you need, let em know and I will edit this question! Thanks so much!
EDIT:
Based on the advise from #buruzaemon, I tried
<img src="{{URL::asset('images/posts')}}/#{{bind-attr src=id}}.#{{bind-attr src=image_extension}}" alt="Post image"/>
and it feels like it's on the right path, but not quite there. Any more advice?
Perhaps you should have a look at bind_attr in Ember.js. It will allow you to set the src attribute properly with value that can be set in your controller.

How do I include the homepage in the Sphinx TOC?

Let’s say I’ve got a Sphinx project with the following sources:
index.rst
installation.rst
templating/
index.rst
module.rst
fieldtype.rst
index.rst (the homepage) has the following TOC tree:
.. toctree::
:titlesonly:
installation
templating/index
I want my template to include a sidebar that lists all 3 top-level pages (homepage, installation, templating/index).
I've tried adding a second, hidden TOC tree in the homepage:
.. toctree::
:hidden:
index
.. toctree::
:titlesonly:
installation
templating/index
That actually gives me the desired result, except that it makes the next variable set to the current page. So this code in my template:
Next up: {{ next.title }}
…always outputs the homepage link from the homepage. No good.
I’ve always tried to hardcode the actual homepage link right into the sidebar of the template:
{% set homeClass = 'current' if pagename == 'index' else '' %}
<ul class="{{ homeClass }}">
<li class="toctree-l1 {{ homeClass }}"><a class="{{ homeClass }} reference internal" href="/index.html">Home</a></li>
</ul>
{{ toctree() }}
That also works, except that I don’t want to force the docs to be accessed on the webroot of a web server – I want them to work from the file system too.
I can’t simply set the URL to “index.html” because that won’t work when you’re in a file within templating/.
Am I missing something obvious? There must be a way to get the homepage into the TOC, without breaking next links and with a dynamic path that works on a local file system, even from within subfolders.
Turns out the answer was hiding in plain sight on Sphinx’s TOC tree page:
The special entry name self stands for the document containing the toctree directive. This is useful if you want to generate a “sitemap” from the toctree.
Adding self to the TOC tree did the trick perfectly! And if you place it in a separate, hidden toctree directive, it won’t show up on the homepage’s table of contents either:
.. toctree::
:hidden:
self
.. toctree::
:titlesonly:
installation
templating/index
Is it possible for you to rename your Sphinx project's root toctree page, or, alternatively, the templating/index page? The master_doc variable lets you name the file in your project that contains the root toctree directive, and it doesn't have to be called index.rst... in our documentation project to get around a problem very like this, we have a template/index.html file and our root toctree page is actually called reference.rst.

add metadata to liquid templates using jekyll plugin

I am new to Jekyll. I have a post with the following yml front matter:
---
layout: images-grid
title: Grid Sample
image: "/imgs/image1.jpg"
---
I would like to create .rb plugin that identifies all the posts with "layout = images-grid" and adds the height and the width of the image as a yaml metadata so the height and the width will be available to the liquid templates.
Is there any way to do this?
could you not do something like this in your file?
{% if page.layout == images-grid %}
// do something
<img src="{{image}}" class="image-class"/>
{% endif %}
I'm looking for something similar (well not really similar, but the goal is the same, use a plugin to edit the front-matter of a post or posts).
So far the only option that I've found is to actually use the ruby File class to open and edit the file. So something like:
fileHandler = File.open("2013-11-23-post-title.html", "w+")
and then read in lines, editing/adding your new content to the front matter as necessary, i.e.:
fileHandler.puts "height: 480px\n width: 640px"
It would be nicer/ideal if the front-matter was available for manipulation as an attribute of the page or post object, but I don't think it is. I'm going to check the project page on github to see if there is already a feature request open for that.

Why is my PyroCMS not building the view I tell it to?

Here is my controller code:
$this->template
->set_breadcrumb( 'my stuff )
->set('questions', $questions)
->set('categories', $categories)
->build('index');
However, it doesn't seem to actually build the index view. It's building my default.html view in my theme.
Ideas?
I don't understand this question or the accepted answer. It will always build the default.html because that is the default layout.
The contents of the index go into {{ template:body }} which you should be echoed out in your layout of choice.
You can't have default.html as a view.

Resources