How to use single quote and double quote as part of title without escaping


#1

How to use single quote and double quote as part of title without escaping. I need single and double quote same time.


#2

Could you give an example? Here’s a working example title with both types of quotes, example.md:

---
title: A winter's "day"
---
{{ page.title }}

#3

Yes, it is working in post title, but can’t use in post name(file name). https://bpmottathai.github.io/testrr/2019/03/07/2018-10-19-test-zcmzxcl


#4

Ah, I see. You can use single/double quotes in a post’s source file names, but the name is translated (“slugified”) when creating the permalink. Double-quotes aren’t allowed in URL paths, so the slugify filter strips them.

You can specify a custom slug with the slug variable in the page’s YAML front matter. However, the slug still needs to use legal URL characters, so double-quotes aren’t allowed.

Example of the default file name slugification:

$ ls _posts
2019-03-07-winter's-"day".markdown

$ bundle exec jekyll build
...

$ ls _site/jekyll/update/2019/03/07/
winter's-day.html

Example custom slug with single-quotes:

$ cat _posts/2019-03-07-winter's-"day".markdown
---
title: A winter's "day"
slug: winter's-'day'
---
...

$ ls _site/jekyll/update/2019/03/07/
winter's-'day'.html

#5

I can’t fully understand you. Can you tell me why here no title shown


#6

Looks like the title is not coming from the filename - is there front matter for that file for title?

If so put the title you want there.

If you need both single and double quotes in yaml you can do it i think - if the title is in the front matter you need to figure out how to do both quotes in yaml. Google yaml syntax and you should find lots of info. You might be able to escape them like \"


#7

@rdyar

Its front matter is like

---
layout: post
title:  "Test"  zc mzxcl
date:   2018-10-19 11:13:14 +0000
---


zxc,mngzC jkzKJ cljkzHGC zlKJChJKZXC KL:SZJ

And file name is 2018-10-19-"test"zcmzxcl.markdown
And I already asked in first post that I need a solution without escaping like \"


#8

the title in the front matter is going to over rule the filename so you will get the title from the front matter no matter what the filename is.

Did chucks example title not work? title: A winter's "day"

In the front matter you can use a > and then go down a line and it should allow just about anything, I think this is called folded style yaml - like:

title: >
    A winter's "day"

Its not exactly clear what you want, sounds like you want the title to come from the filename, and the filename needs to contain both types of quotes? if so I don’t think that is possible.


#9

This is incorrect YAML
You’ve to include the whole thing in quotes:

title:  '"Test"  zc mzxcl'

If you want to include both single-quotes and double-quotes in the title, then use the “folded” syntax recommended in the other answers…


#10

Thanks all, folded style is working.
Meantime my script looks like

  def post_header(name)
    <<-HEREDOC
---
layout: post
title:  >
    #{name.capitalize.gsub(/[!]|[$]|[(]|[)]|[;]|[&]|[*]|[@]|[#]|[%]|[']|[:]|[.]|[,]/, ' ')}
...

Do I really need to substitute special chars in name.capitalize.gsub?


#11

Your page’s title is what appears in your page’s SEO stats, search results and browser tab. Stripping away special characters and keeping it simple helps in improving user experience.

Also, your regex above can be simplified to:

/[!$();&*@%':,]/

#12

Okey, thanks…