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/"
Related
If you make a Gallery in Batflat CMS, the template tag it creates will generate its only Bootstrap HTML for a gallery. What if I just want to emit IMG tags for the gallery items, instead?
Create a Gallerymod custom module. That way, your customization may likely survive a Batflat Update.
Copy inc/modules/galleries as inc/modules/gallerymod.
Remove the lang folder and Admin.php in your gallerymod folder.
Change the Name and Description inside the gallerymod/Info.php, as well as the comments. I used static strings instead of code. Also in this file, inside the install function and uninstall function, remove code inside those so that it does nothing on install or uninstall.
In your gallerymod/Site.php, look for the $assign[$gallery['slug']] assignment, and on the following line, add:
$assign[$gallery['slug'] . '-alt1'] = $this->draw('gallery-alt1.html', ['gallery' => $tempAssign]);
Also, where you have the namespace line set as namespace Inc\Modules\Galleries;, change it to namespace Inc\Modules\Gallerymod;.
In your gallerymod/view folder, create a gallery-alt1.html file and add these contents:
{loop: $gallery.items}
<img class="photo-{if: $value.title}{$value.title}{/if}" alt="" class="img-responsive" src="{?=url($value.src.lg)?}">
{/loop}
Now activate this inactive module in Batflat's admin system. You'll notice that it has no admin panel -- because it doesn't need one. You already have the Galleries one. Do not deactivate the Galleries module because the Gallerymod module relies on the Galleries module.
Now, from your custom theme template, you can call this by varying how you called the old slug. So, if your old way of calling the gallery was something like {$gallery.home-photos}, then you would merely tack on the "-alt1" on the end and call it like {$gallery.home-photos-alt1}. I like to wrap these in a DIV wrapper with an ID on it so that I can address it with CSS, jQuery, or Javascript.
In the Batflat Admin system, go back and edit your image titles in the gallery. Treat those titles like a slug (lowercase alphanumeric phrase with dashes) because these are used as class names on the IMG tags in gallery-alt1.html, and you may want to address these individually in CSS, jQuery, or Javascript, later on.
Refresh your browser and you may see the source code display something similar to:
<div id="hidden-images" class="hidden">
<img class="photo-man2" alt="" class="img-responsive" src="https://example.com/uploads/galleries/2/15831273220.jpg">
<img class="photo-woman1" alt="" class="img-responsive" src="https://example.com/uploads/galleries/2/15831272980.jpg">
<img class="photo-man1" alt="" class="img-responsive" src="https://example.com/uploads/galleries/2/15831272540.jpg">
</div><!-- hidden-images -->
Just remember that if you update your version of Batflat, that you may need to reapply this customization again -- it depends on what was done in the update to the existing Galleries module.
If you have different tastes as to how you want to format your images, just edit your gallery-alt1.html file. Plus, you can make multiples of these for different situations, such as gallery-alt2.html, gallery-alt3.html, etc. You can even make it emit JSON instead of html so that you can insert it into a Javascript block in your theme.
Another tip for debugging, in case your site won't load or the admin system breaks, is to edit inc/core/defines.php and change the DEV_MODE to false. That way, PHP will show you every error and that might help you in debugging what might be wrong.
I'm using Laravel, and have a view structure like such:
Each of my pages have a navbar at the top, and the navbar has a few links on it:
<ul class="uk-nav uk-navbar-dropdown-nav">
<li>KENNEL INFORMATION</li>
<li>SIRES & DAMS</li>
<li>LITTERS</li>
<li>HELP</li>
</ul>
If I click one of these links (lets say info) from the homepage (home.blade.php), it redirects to the following url:
localhost:8080/mykennel/info
However, if I'm already on a view that is in the mykennel subfolder (again, lets say I'm on the info page), and I click a link from the navbar, it redirects to:
localhost:8080/mykennel/mykennel/info
Which throws a 404. I understand WHY this is happening but I can't seem to find how to fix it. How can I create an href in my anchor tag that knows to use only a single /mykennel/ prefix, regardless of where the user is currently situated on the site?
Any help is appreciated.
Try to use an absolute path instead, by adding / at the beginning of the href so links:
<ul class="uk-nav uk-navbar-dropdown-nav">
<li>KENNEL INFORMATION</li>
<li>SIRES & DAMS</li>
<li>LITTERS</li>
<li>HELP</li>
</ul>
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 }}
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.
In my view I'm trying to create an anchor tag but CodeIgniter is prepending my entire host before what I specify as href, therefor making it invalid.
I put this
My File
I get
My File
EDIT 3
This is my view, I realise i should not be calling a function in my view but in this case I had little option as something needs to get applied for each data item in the loop, I will try to change this but thats beyond my problem right now.
Wesley: I checked the soruce and it displays correctly in the source but in the browser it preappends the host so I guess this has nothing to do with code igniter afterall! How do I make sure it doesn't happen?
<td><?php
$this->ci = &get_instance();
echo $currentData["field_one"] . " - Log"; ?>
</td>
EDIT 4
my html source
<a href="file:://///\\myhost.local.com\120">
View Log
</a>
my url address bar
http://myhost.local.com/myhostlocal/index.php/level/one/type/b/cc/ee/
the url it goes too when I mouse over the href
http:///myhostlocal/index.php/level/one/type/b/cc/ee/file:://///\\myhost.local.com\120
Looks like the browser is treating "file:://///" as a relative path. Why do you have 2 colons, do you need both? Removing one will provide a valid protocol, and the browser will start treating it as an absolute path.