mmistakes / minimal-mistakes

:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
https://mmistakes.github.io/minimal-mistakes/
MIT License
12.33k stars 25.5k forks source link

Extra spaces (and blank lines) introduced in html files #1506

Closed floatingpurr closed 6 years ago

floatingpurr commented 6 years ago

Environment informations


I've marked this post as a question because probably I'm using the theme in a wrong way.

Expected behavior

In my _config.yml file I set:

title: Foo
title_separator: "|"

When I build pages, I expect to have pages titles like:

<title>Page Title | Foo </title>

instead I have something like this:

<title> Page Title Foo </title>

with a lot of extra spaces (see the source of this markdown).

  1. Why isn't there any |?
  2. Why are those extra spaces introduced in html files? (It happens not just inside that tag. There are also a lot of blank lines in the generated html).

Is there a way to avoid those issues?

mmistakes commented 6 years ago

You have a link to a public repo? I can't help troubleshoot your issue without it.

floatingpurr commented 6 years ago

Hello, I've just loaded the code here: https://github.com/floatingpurr/test : )

You can see the problem in action in _pages/blog/index.html

mmistakes commented 6 years ago

Ah yeah seen this one before. You have to use | as a HTML entity, since it breaks some of the Liquid code if you don't.

See this issue for the fix.

https://github.com/mmistakes/minimal-mistakes/issues/760

floatingpurr commented 6 years ago

Thank you so much! Excuse me if I take advantage from this discussion for a coupe of little things without opening up a new one.

Hint: in the theme guide there is the statement

Example: title_separator: "|" would produce page titles like Sample Page | My Awesome Site.

It could be useful specifying this problem : )

Follow up: I still see a lot of blank lines among tags in generated html files. Is this a problem related to this theme or it's just a characteristic of jekyll template system?

Thank you once again

mmistakes commented 6 years ago

Happy to accept a pull request if you want to update the documentation files to include a note about using title_separator: "|".

As far as blank spaces and lines. Do you mean in the actual rendered page? Or in the HTML source? If its the source that's a side effect of Liquid. You'll see a bunch of blank lines and inconsistent indentation due to for loops and conditionals.

Liquid 4 allows you to collapse some of that, but it doesn't completly remove it. It's a non-issue if you ask me. On my personal site I pipe all my .html files through minifiers to strip all that out and reduce the file sizes for improved page load.

floatingpurr commented 6 years ago

Yes, exactly, I mean the HTML source. Minifiers are a good hint.

I saw you have fixed docs in commit 1c0f191. Thanks for your support!

mmistakes commented 6 years ago

No problem. I also made a small fix to the seo.html include. It automatically replaces | with the HTML entity now, so it should work making that the separator in _config.yml.

floatingpurr commented 6 years ago

@mmistakes, great job :clap: