Can I create links with 'target="_blank"' in hugo posts content using Markdown? - html

I use Hugo to deploy static web, using Markdown and the problem I would like to sort out is simple.
I would like to find the simplest and compatible with Markdown language way to make my web links open in different tab.
The method I use now is below:
< rawhtml >}}Rasmus Lerdorf</br>{{< /rawhtml >
[link with title](http://nodeca.github.io/pica/demo/ "target="blank")
First method working but it is HTML second method not working.
Thank You.

You need to create a new file at /layouts/_default/_markup/ called render-link.html.
In that file, you can then customise it to something like:
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
Here is what would happen:
[link1](../something/ title="title") => link1
[link2](https://example.com) => link2
It will only add it to URLs with "http" and "https".
The documentation for render-hooks is available here: https://gohugo.io/templates/render-hooks/.

Or you could just put the link in as you have it using regular, old HTML.
IMHO, beating yourself up over the failings of Hugo and whatever theme is in use is counter-productive. Markdown was supposed to be a quick and dirty way for users who couldn't grasp the basic fundamentals of html to create and display content on a wiki.
Think about the current situation. Does using Hugo, a theme, and Markdown really save any effort when they simply can't produce the output you need because the features you need don't exist in that combination natively?
When you need to spend hours/days researching and learning how to manipulate the generator's template to generate the output you need from Markdown and Hugo, tell me, where exactly are those time savings?
This is why people using tools such as Flare, RoboHTML, and Paligo laugh at users who brag about how fast they Hugo site generates html pages.

Related

How to organize multiple outputs inside a single Jekyll project?

I use Jekyll to create documentation for software products. I have 30 +
different products that have a common LIQUID template but different content. Every single product documentation has its own table of content.
For one project, everything is OK. I have a content folder as well as css/js folders. I run "jekyll serve" and publish a project.
The problem is that, I do not want to have 30 Jekyll projects stored one next to another with similar css, configs, js folders and will only differ in content part.
The question is: how can I organize the internal structure so I have a
single project with a common layout and 'x' different content folders inside the single project?
Like:
_product1/
some_subdir
'topic.md'
_product2/
some_subdir
'topic.md'
If it's possible, how can I then manage the output? I need to publish product 1 and product 2 ... product 'x' separately.
Thank you for the assistance.
UPD: Here is the demo project on GitHub: https://github.com/plywoods/JekyllDocumentationDemo
The way to have this content separation in Jekyll is through the use of Collections.
Here is an example of a Jekyll website using Collections:
https://github.com/netponto/netponto.github.io
_meetings, _members, and _sessions are different collections and analogous to your _product1, _product2, etc.
You can customize the output / how the URL is going to be in the _config.yml of your Jekyll site. For example:
collections:
meetings:
output: true
permalink: /reunioes/:path/
sessions:
output: true
permalink: /sessoes/:path/
To display the items of a collection, for example the "sessions" collection, you do something like this:
{% for session in site.sessions %}
<p>{{ session.title }}</p>
{% endfor %}
If you're having issues implementing the Collections, put together a reproducible example on GitHub, so that others can see what you've tried to do and point what's missing.

How can I add a new category to a morea site?

I'm trying to add a new 'project' category to a morea based site, where there will be a page similar to experiences page where I'll collect all course project related experiences and assignments, and maybe even modules.
Is it ok to look for pages with 'project' in their id or maybe better to tag with a new morea tag?
Do I need to also create a new entity type called 'project' or just reuse existing entities
In MoreaGeneraor.rb I couldn't find where module level page collections are prepared, like for example module_page.data['morea_experiences'].
I thought of preparing a similar collection of 'morea_project' pages and then traversing it in the new project page.
Is that done outside of this .rb file? by Jekyll? so how do I inject my collection.
Any simpler idea?...
Thank
p.s. I've also added the following (from line 3) to 'processMoreaFile()', but it does not seem to be visible at later stages:
elsif new_page.data['morea_type'] == "assessment"
site.config['morea_assessment_pages'] << new_page
if new_page.data['morea_id'].include?('project')
site.config['morea_project_pages'] << new_page
puts "--- project page #{new_page.data['morea_id']}\n "
end
but still do not know where to let each module page find out about it's 'project' pages
This is a cool idea. The simplest approach is to avoid making changes to MoreaGenerator.rb, and instead do it using normal Jekyll mechanisms. Here's a sketch:
Add a morea_label called "Project" to each associated module, reading, experience, and assessment.
In master/src, create a new directory called project, containing a file called index.md. This adds a new top-level page to your site (i.e. http://example.com/ics101/project/index.html)
Implement the index.md file with liquid tags to create the desired page layout for your project page. For inspiration, see the index.md files in the other top-level pages (readings, experiences, etc.). You can access YAML content in Liquid.
Once you've got your rocking project page done, you'll want a link to it in the navbar. See add a menu item for instructions.
Good luck! If you get it working to your satisfaction, please post its link as a followup to this question so we can see how it turned out!

Jekyll - link to posts from pages

A very basic question.
I can not find out how to refer or cite a post in a page.
If this is my post
---
layout: post
title: "Serve Jekyll Websites with servr and knitr"
categories: [jekyll, rstats]
tags: [knitr, servr, httpuv, websocket]
---
The R package [**servr**](https://github.com/yihui/servr) can be used to set up an HTTP server to serve files under a directory.
How I am suppose to cite it in my page
---
layout: page
title: About
permalink: /about/
---
You can find out more info in this post
Could you help me out ?
You can do this 2 ways:
Copy-pasting the link generated for your post as a link to it.
[Check Out My Post!](www.example.com/posts/2015-10-1-name-of-post/)
This definitely works, but will break/fail when you decide to change link style, or have another permalink, or when you change file names.
The smarter way: Jekyll's built in post_url
Jekyll has a built in function that allows you to internally link or cite back to posts on your website. Here is the documentation for it, but I will explain the syntax and usage as well.
Assuming you want to link to a Jekyll post with the filename of 2015-07-17-jekyll-servr-tutorial.md which is located in the _posts folder, the syntax for this would be:
{% post_url 2015-07-17-jekyll-servr-tutorial %}
{% post_url /tutorials/2015-07-17-jekyll-servr-tutorial %} if you have your posts organized in a subdirectory called tutorials
The R Package [servr]({% post_url 2015-07-17-jekyll-servr-tutorial %}) if you want to make hyperlinks.
There is no need to include the file extension name when using this liquid tag function.
Here is additional information and a tutorial on how to use Jekyll post-links that you might find useful as well.

Generating a pdf-file out of a twig template

I want to generate a pdf (an invoice as letter) out of a twig template. The template uses a css and contains a header with a logo (png-image) and a footer, which should appear at the bottom of the document.
I tried it with the KnpSnappyBundle, but this doesn't work (css only works inline, images are not rendered..., etc.). Are there any other tools to generate a pdf?
With Java I used jasper-reports (really cool), isn't there anything similar for php?
I have used KnpSnappyBundle to generate pdf before, and it worked with external css files, thought there's is some diffrence bettween regular tempaltes:
When linking asset you have to provide absolute path:
<link type="text/css" rel="stylesheet" href="{{ asset('css/css.css', null, true) }}" />
I didn't needed images files, but I think it should work the same, also you need to use "renderView" method instead of "render".
$pdf = $this->renderView('**:**:tempalte.html.twig', array());
After that you just simple use:
$file = $this->container->get('knp_snappy.pdf')->getOutputFromHtml(pdf);
The answer is: The server startet via
php app/console server:run
is single-threaded, so there is no chance, to get a response, when requesting an image or css-file...

html template without using php or rails ect

I am looking for a way to code html templates without using any "backend" languages like php or ruby/rails.
using JS could work but i have issues with my current javascript when i add nodes after the DOM is loaded.
the solution that would be ideal is if there is a preprocessor of some kind that i can compile into finished html.. something similar to SCSS but for html
just so i'm clear and i have enough content for stackoverflow..
i want partial.folders content to compile into index.html
partial.folder
menu.html
root.html
footer.html
|
|
V
index.html
Depends on "when" you want to parse the templates.
1) At runtime: you could try to use https://github.com/janl/mustache.js - javascript Logic-less templates
2) At build time: I would suggest using nodejs+Grunt (http://gruntjs.com/) + grunt-preprocess (grunt plugin)
I found an answer to my own question. a program called codekit worked exactly how i wanted it to. thanks for the help! http://incident57.com/codekit/