S2 Cookbook: Adding custom content to your page head

From Dreamwidth Notes
Jump to: navigation, search

This recipe contains instructions for you to add custom content to the <head> section of your journal.

Determine your layout and theme

First, you will have to know what layout you are using and what theme. You can find that information on the Customize Style page:

http://www.dreamwidth.org/customize/

Your theme name will be by the thumbnail in the standout box, with the layout name below it as a link.

When you know these things, go here and find your layout:

http://www.dreamwidth.org/customize/advanced/layerbrowse

Click on the X children... link to list the themes for that layout, and your theme should be listed there (unless it is one you customly made, in which case go to the Add the print_custom_head() function). Click on the "Raw Source Code" link. This is your theme layer!

Create a new theme layer

Then, go here in a different browser window and create a new layout-specific layer: a theme with your layout as the layout.

http://www.dreamwidth.org/customize/advanced/layers

Copy the contents of the theme layer you found into your new theme layer.

Take out this line defining redist_unique, for example:

layerinfo redist_uniq = "crossroads/cinnamoncream";

You might also want to change the name defined here to help you keep track of this specific:

layerinfo name = "Cinnamon Cream -- Custom head";

Add the print_custom_head() function

Now, at the end of the layer you are editing, add a function like this:

function Page::print_custom_head() {
    """META TAGS GO INSIDE THESE QUOTE MARKS""";
    """ANOTHER THING TO GO INTO YOUR HEAD YAY""";
}

Remember the ; at the end of the line.

Change what layers your style is using

Now, go to this page:

http://www.dreamwidth.org/customize/advanced/styles

The style you are currently using is in bold (this is not best accessibility practice, but the page is due for an utter revamp anyway). Edit it. Change the theme listed to the one you have just created. This shouldn't override any customizations you've made in the wizard--just leave that selection box alone! Then, save the changes.