SEO-related issues

53 views
Skip to first unread message

EJelome

unread,
Sep 7, 2012, 5:09:05 AM9/7/12
to blogofil...@googlegroups.com
Hi everyone, newbie here.

I just want to know how is it possible to use the YAML in the <body>, especially in the <head> of the web page. I can't seem to find any examples on the docs and the web.

For example, if I put the following:
---
robots: noindex, nofollow
---

How can I access that 'robots' to be usable in the web page itself. My goal is to put it to the <meta />, like the following:
<meta robots="robots" content="${}" />

Doug Latornell

unread,
Sep 7, 2012, 9:33:48 AM9/7/12
to blogofil...@googlegroups.com
On Fri, Sep 7, 2012 at 2:09 AM, EJelome <eje...@gmail.com> wrote:
> Hi everyone, newbie here.

Welcome!
The YAML header data is available for use in templates in the post
namespace. So, with the default templates, you should be able to get
what you want with:

<meta robots="robots" content="${post.robots}" />

in the _templates/site.mako file.

EJelome

unread,
Sep 8, 2012, 7:59:04 AM9/8/12
to blogofil...@googlegroups.com, d...@douglatornell.ca

Hi Doug,

When I  tried your solution and rebuild blogofile (to apply the changes), it returns an error.
I do:
>> blogofile build -s blogname

Then it returns the following:

ERROR:blogofile.template:Error rendering template: permapage.mako

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/template.py", line 157, in render
    rendered = self.mako_template.render(**self)
  File "/usr/local/lib/python2.7/dist-packages/mako/template.py", line 412, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 766, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 798, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 824, in _exec_template
    callable_(context, *args, **kwargs)
  File "_templates/base.mako", line 2, in render_body
    ${next.body()}
  File "_templates/site.mako", line 12, in render_body
    <meta name="robots" content="${post.robots}" />
  File "/usr/local/lib/python2.7/dist-packages/blogofile_blog-0.8-py2.7.egg/blogofile_blog/site_src/_controllers/blog/post.py", line 291, in __getattr__
    raise AttributeError(name)
AttributeError: robots

ERROR:blogofile:Fatal build error occured, calling bf.config.build_exception()
Traceback (most recent call last):
  File "/usr/local/bin/blogofile", line 9, in <module>
    load_entry_point('Blogofile==0.8-DEV', 'console_scripts', 'blogofile')()
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/main.py", line 58, in main
    args.func(args)
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/main.py", line 388, in do_build
    writer.write_site()
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/writer.py", line 49, in write_site
    self.__run_controllers()
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/writer.py", line 162, in __run_controllers
    controller.run_all(namespaces)
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/controller.py", line 229, in run_all
    c.mod.run()
  File "/usr/local/lib/python2.7/dist-packages/blogofile_blog-0.8-py2.7.egg/blogofile_blog/site_src/_controllers/blog/__init__.py", line 80, in run
    permapage.run()
  File "/usr/local/lib/python2.7/dist-packages/blogofile_blog-0.8-py2.7.egg/blogofile_blog/site_src/_controllers/blog/permapage.py", line 12, in run
    write_permapages()
  File "/usr/local/lib/python2.7/dist-packages/blogofile_blog-0.8-py2.7.egg/blogofile_blog/site_src/_controllers/blog/permapage.py", line 38, in write_permapages
    "permapage.mako", bf.util.path_join(path, "index.html"), env)
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/plugin.py", line 135, in materialize_template
    lookup=lookup, caller=self.module)
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/template.py", line 388, in materialize_template
    template.render(location)
  File "/usr/local/lib/python2.7/dist-packages/Blogofile-0.8_DEV-py2.7.egg/blogofile/template.py", line 157, in render
    rendered = self.mako_template.render(**self)
  File "/usr/local/lib/python2.7/dist-packages/mako/template.py", line 412, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 766, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 798, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/local/lib/python2.7/dist-packages/mako/runtime.py", line 824, in _exec_template
    callable_(context, *args, **kwargs)
  File "base_mako", line 23, in render_body
  File "site_mako", line 36, in render_body
  File "/usr/local/lib/python2.7/dist-packages/blogofile_blog-0.8-py2.7.egg/blogofile_blog/site_src/_controllers/blog/post.py", line 291, in __getattr__
    raise AttributeError(name)
AttributeError: robots
 
I think I have to declare the keyword 'robots' somewhere (correct me if I'm wrong) so the compiler will know that it exist, only that I don't know where should I put it.

EJelome

unread,
Sep 8, 2012, 10:39:56 AM9/8/12
to blogofil...@googlegroups.com, d...@douglatornell.ca
Hi Doug,

Using the default installation, I have managed to make it work, however, not in the directory and file you specified but in:
_templates/blog/post.mako

If I try to access it outside this file, it causes an error.
I guess I'll need to study a bit of Mako first then.
Thanks for your help!

Regards,
EJelome
Reply all
Reply to author
Forward
0 new messages