Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Adding <link> headers

Started by Muut Archive 10 years ago · 5 replies · 434 views
10 years ago

Is there a "Grav" way of injecting material into the final output's <head> tag? Specifically I want to add some <link> tags. I know I can just grab the final output from onOutputGenerated and just append some stuff just before </head>, but I thought I'd check to make sure there wasn't a "better" way. Thanks!

10 years ago

I am no expert, but if you look in the template partial that generates the <head> section you should be able to put anything you want in there.

10 years ago

Thanks. Yes I could, but this is for a plugin. I want it to inject the tags so the user doesn't have to mess with their templates if they don't want to. I want it to be automatic and transparent.

10 years ago

Right. As I said, I'm not nearly expert enough to do that. But as plugins seem to be able to inject content into other partials, I'm pretty sure someone could do it.

10 years ago

Hmm.. actually there really isn't programatically. You can do it via Twig of course but that depends completely on the theme because it may or may not define the block head.

I think your approach is best for now. It will take some wholesale changes in all themes to support adding arbitrary header options.

10 years ago

OK. I'll go with the brute force method. Thanks :)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1362 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2959 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago