How can I update the copyright information in hugo theme? - blogs

I'm using hugo theme for my IOS blog and updated the footer copyright information, but every time the website loads it loads the default copyright information from the original theme. How can I update the copyright information?

Can the copyright message in the footer be enabled to display the current year dynamically?
Change line 9 in layouts/partials/footer_section.html using a token, such as {currentYear} that is searched and replaced:
{{ with .Site.Copyright }}{{ . | markdownify}} · {{ end }}
to
{{ with replace .Site.Copyright "{currentYear}" now.Year }}{{ . | markdownify}} · {{ end }}
and have the copyright text display in config/_default/config.toml display something like:
copyright = "© 2010 - {currentYear} My Name"
The user can choose not to have {currentYear} in the copyright text or leave it blank.

Related

How to show the correct title for my blog post and not just the latest title using markdown

I am trying to creating a blog on my website using markdown but I am having trouble with the blog titles.
I have created a loop to bring in the latest title and excerpt onto my home page which works fine.:
{% for post in site.posts limit: 1 %}
On my site I have a list of my blogs (https://jenjnif.github.io/blog.html)
and when you click on one to read the whole blog I would the title for only that blog to show up.
I used the same code as above {% for post in site.posts limit: 1 %} to only show one title as all blog titles were showing without this but obviously then it will only show the latest title regardless of which blog I am actually viewing. Here is the markdown for that page:
---
layout: default
---
<div id="post">
<div class="blog-header">
{% for post in site.posts limit: 1 %}
</div>
<h2 class="blog-title">{{ post.title }}</h2>
{% endfor %}
{{ content }}
</div>
I know the limit: 1 will not work because it is only then going to take the latest title but I don't know how else to get only one title showing up on each blog post. Is there a way to make sure only one title shows - only showing the correct, current blog title, not all of them?
All files can be found in my GitHub repository: https://github.com/jenjnif/jenjnif.github.io
When using Jekyll and its Liquid templating engine, they have several sets of variables. Instead of using a for loop to go through all the posts, you can use page.title to get the title for the current blog post.
<div id="post">
<div class="blog-header">
</div>
<h2 class="blog-title">{{ page.title }}</h2>
{{ content }}
</div>

md (markdown) pages giving 404

I've recently started using GitHub pages and I'm facing the following issue. As you can see in my repository, I have a _posts to store my blog markdowns. I have used the naming convention of YYYY-MM-DD-title-of-my-post.md.
Now, as you can see with 2017-12-25-shivang-bhatt-site-launched.md, the content inside is as follows:
---
layout: post
title: "Shivang Bhatt, Launches Site"
date: 2017-12-25
---
Well...some text.
Now for the layout part of this, my _layouts contains a post.html with the following content:
---
layout: default
---
<h1>{{ page.title }}</h1>
<p class="meta">{{ page.date | date_to_string }}</p>
<div class="post">
{{ content }}
</div>
The issue I am facing is this. The URL which should host this post page, http://s-bhatt.github.io/2017/12/25/shivang-bhatt-site-launched, is giving a 404 - File not found.
I would be extremely grateful for any help or pointers regarding this issue.
In your _config.yml you have set the permalink:
permalink: /post/:year/:month/:day/:title
so following the filename convention for posts, 2017-12-25-shivang-bhatt-site-launched.md will be at http://s-bhatt.github.io/post/2017/12/25/shivang-bhatt-site-launched, that is, inside the post folder.
If you want to make it work with the url you tried, just remove post from permalink like:
permalink: /:year/:month/:day/:title
The right address is
http://s-bhatt.github.io/post/2017/12/25/shivang-bhatt-site-launched
Note /post in the middle of it.

{{ content }} Liquid tag not showing blog posts

Link to repo: https://github.com/AlvSovereign/AlvSovereign.github.io
I am coding my portfolio site, with a link to my blog. The fully processed portfolio site sits in _site/index.html which contains a link to the blog (fully processed link exists in _site/blog.html)
Blog.html at the root of the repo has in the front matter a layout of "bl", which is defined in my layouts folder under "bl.html".
"bl.html" is the layout I want for my blog page, which contains my includes etc. It also contains the {{ content }} liquid tag.
If I am thinking about this the right way, my posts are being parsed (I think this is the right terminology) into "post.html" - which has the front matter "layout: bl", which then parsed into "bl.html", and that this is so as they both have {{ content }} in each files.
Now all my posts are showing correctly (i think) within _site/(year)/(month) etc. However, they are not ending being parsed through my "blog.html" file, and then visible on my webpage. How I know this is that the fully processed "blog.html" file does not have any of the posts in them.
What will I need to do to solve this issue?
If it helps, I use Prepros for LiveReload, and using LANYON template, http://lanyon.getpoole.com/
{{ content }} refers to all the content that in the file that is being converted to HTML code.
For example, if you are passing a blog post on 'What is Jekyll' to any layout that has the {{ content }} tag, all text other than the YAML front matter will be put in that place. Basically the content of the post. You can also limit the scope by using {{ post.content }}, see Variables for more info here.
So the Liquid {{ content }} variable works as intended.
Looking at your website, I believe you're trying to display all the posts in your blog.html file, so what you're actually asking about is why aren't my posts being displayed (not parsed) in your blog.html file, hence not visible on your webpage.
The reason for that is because you shouldn't use {{ content }} tag for that, what you want instead is something like this snippet of code as mentioned in the Jekyll docs, that will grab all your posts, and display them by post title, as well as a link to that post. Here's the code to display a list of your posts. (taken from the website I linked you)
<ul>
{% for post in site.posts %}
<li>
{{ post.title }}
</li>
{% endfor %}
</ul>
So just swap out {{ content }} in your bl.html layout with that code snippet and you've got what you want.
Additionally, if you also want to display the content/excerpt in the list of posts, just add the liquid tag {{ post.content }} or {{post.excerpt}} like so:
<ul>
{% for post in site.posts %}
<li>
{{ post.title }}
{{ post.content }} /* or post.excerpt */
</li>
{% endfor %}
</ul>
Of course, edit the HTML accordingly for your preference. Read the documentation on how to set up post excerpts here, which uses the <!--more--> comment separator for excerpts.
I strongly recommend reading the JekyllRb documentation for more information, it's a lot to read and not always easily understandable, but keep referring to it and you'll understand more in no time.

Show blog post title in meta information

I'm working on Search Engine Optimization for my Jekyll site, and I am running into an issue where I am unable to set meta information.
...
<meta name="og:title" content="{{ seo_title }}" />
...
<!-- now in my for post-loop: -->
{% for post in site.posts %}
<li class="post-link">
<a class="post-title" href="{{ post.url }}">
<span class="post-date">{{ post.date | date_to_string }}</span>
{{ assign seo_title = post.title }}
{{ post.title }}
</a>
</li>
{% endfor %}
I'm assigning sel_title to the post title, but it's not showing up in my meta information! I just get <meta name="og:title" content="" />
I've also tried adding {{ assign seo_title = page.title }} inside of my post.html post layout to no avail using {{ page.seo_title }} {{ post.seo_title }} and {{ seo_title }}
Now, obviously this really isn't what i want, because logically - after this for loop, it would set it to whatever the last post title was, but i can't even get that to display. Ideally what I would like, is for it to show up for the post.
You can view the page here where I want it to show up.
Where am I going wrong? How can I use my post information to fill my SEO meta information?
Had a look at your github repo. You are using only one basic layout for both index and posts. In your _posts, the YAML Front Matters is getting processed first time (and only once) when you do {% include post.html %}. But then you pass it on to the default layout and you cannot pass the YAML variables from the post through also.
One typical pattern you can adopt is split the default layout and create partial html files in the _includes folder i.e header.html and footer.html. You can then use them to create your default and post layouts. That way you can pass on the relevant YAML Front Matter variables in the post to the header.

Jekyll is not correctly reading page title

I'm running into a new error after updating to the newest version of Jekyll, where it's giving me an
Here is part of the error message after running jekyll build:
___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Bad block-level HTML:
| |#<MaRuKu::Exception: Error: Malformed: tag <p> closes <a>
| |HTML READER
| | state=inside_element match="</p>"
| |Tag stack = ["ul", "li", "a"]
| |Before:
| ||<ul class="compact recent">
| ||<li>
| || <a href="/blog/hello-world.html" title="<p>Hello everyone—just getting the website set up, so it might take a while for more to appear here.</p>
| |After:
| ||">Hello world!</a>
The post in question consists of:
---
layout: blog-post
title: "Hello world!"
published: true
---
Hello everyone---just getting the website set up, so it might take a while for more to appear here.
Check back later for information about my research, papers, etc.
While the page running into the error is using:
<ul class="compact recent">
{% for post in site.categories.blog limit:3 %}
<li>
{{ post.title }}
<span class="date">{{ post.date | date_to_string }}</span>
</li>
{% endfor %}
</ul>
Any ideas as to why it isn't getting the title properly? This worked fine in an earlier version of jekyll.
Removing the title attribute, and making sure the posted code block was separated by the previous text by an empty line, fixed this problem.