Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variable to tell if page is a draft #1470

Closed
mgp opened this issue Aug 29, 2013 · 6 comments
Closed

Add variable to tell if page is a draft #1470

mgp opened this issue Aug 29, 2013 · 6 comments

Comments

@mgp
Copy link
Contributor

@mgp mgp commented Aug 29, 2013

I have Disqus comments enabled on each post of my blog by including its universal code at the end of my _layouts/post.html file.

If I run Jekyll locally with --drafts, and preview the page, then when the universal code executes, it automatically creates discussions on Disqus with URLs like:

http://localhost:4000/2013/08/28/my-page-title/

Whereas when I finally publish and serve it through omgitsmgp.com, a new discussion is created on Disqus with a URL like:

http://omgitsmgp.com/2013/08/28/my-page-title/

Now I can override the Disqus JavaScript configuration variables disqus_identifier and disqus_url so that, even when I run Jekyll locally, it creates a discussion with an URL starting with http://omgitsmgp.com instead of http://localhost:4000.

But it's not a complete solution, because if I write a draft over multiple days, it creates multiple URLs like http://omgitsmgp.com/2013/08/28/my-page-title/, http://omgitsmgp.com/2013/08/29/my-page-title/, etc. until finally published.

To remedy this, I was hoping that a draft could set a variable like draft to true, and I could wrap the universal code in a conditional {% unless page.draft %}.

Other solutions revolve around including enable_disqus: true in _config.yml, and then:

  • Allowing allowing you to override overriding this option through a command line flag.
  • Allowing specifying multiple configuration files, like --config=_config.yml,_local_config.yml. The file named _local_config.yml could contain the single line enable_disqus: false, overriding enable_disqus: true in _config.yml.

Perhaps I'm missing an existing solution?

@maul-esel
Copy link

@maul-esel maul-esel commented Aug 29, 2013

Multiple config files are supported already: http://jekyllrb.com/docs/configuration/#build_command_options

@mattr-
Copy link
Member

@mattr- mattr- commented Aug 29, 2013

And to expand on the previous comment, by specifying in a separate config
file that you're in development mode through a YAML variable, and using
that new config file when you work locally, you could avoid creating the
Disqus discussion entirely until you publish the site.

On Thu, Aug 29, 2013 at 2:52 AM, maul-esel notifications@github.com wrote:

Multiple config files are supported already:
http://jekyllrb.com/docs/configuration/#build_command_options


Reply to this email directly or view it on GitHubhttps://github.com//issues/1470#issuecomment-23472470
.

@parkr
Copy link
Member

@parkr parkr commented Aug 29, 2013

Boom. I think this solves the problem, though not as precisely. I think adding page.draft for all drafts makes a heck of a lot of sense.

@mgp
Copy link
Contributor Author

@mgp mgp commented Aug 29, 2013

Thanks! I had no idea that multiple configuration files, separated by commas, were supported already. That renders this issue moot. If it sounds good, tonight I'll make a pull request to clarify this in the docs, since I don't think "Specify a config file. Overrides settings in _config.yml" makes it immediately clear.

Thanks again!

@mgp
Copy link
Contributor Author

@mgp mgp commented Aug 30, 2013

For posterity, wrote a blog post describing the problem and solution in full. Thanks all!

@wejrowski
Copy link

@wejrowski wejrowski commented Nov 12, 2014

hmm I was looking for this feature so I can flag drafts on my index view just to be able to tell what was what.

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants