I want to do this:
[i]{{ .Content }}
The content should be displayed at the same line, not in a new line. (Playnify isn't good, because it will remove any newline within .Content as well and I want to keep these.)
Any ideas?
Related
I have one question about when I call dangerouslySetInnerHTML, would cause line break.
If i replace them with spaces, it would work
please check my codesandbox
https://codesandbox.io/s/dangerouslysetinnerhtml-4u16s
Non-breaking space ( ) and a normal space () has different char code.
console.log(example.textContent[0].charCodeAt(0));
console.log(example.textContent[1].charCodeAt(0));
<div id="example"> </div>
When you connect words using , the browser will not break the connecting words because of its non-breakable property. Hence, the browser will parse it as if it is one long word.
Just like normal long word, browsers won't break the word unless you have word-break style set differently.
I believe the code below can further demonstrate the difference:
div {
width: 30px;
border: 1px solid black;
}
<div>I have a pen and I have an apple</div>
<div>IhaveapenandIhaveanapple</div>
<div>I have a pen and I have an apple</div>
How can I have /posts as homepage?
Should I redirect, change the baseURL in hugo 1config or make changes in
the theme 2config?
Footnotes
1 https://gohugo.io/getting-started/configuration/
2 https://github.com/luizdepra/hugo-coder/wiki/Configurations
You can modify the home.html file, as the index.html file is embedding it and there is nothing else in index.html
https://github.com/luizdepra/hugo-coder/blob/master/layouts/partials/home.html
Make the changes in the above file in theme/layouts/partials/home.html these changes will take effect on the site as soon as you save the file (if you are already running $ hugo server -D)
For me, it helped to add a layouts/index.html file to my theme. Here is its content:
{{ define "main" }}
{{ $pag := .Paginate (where site.RegularPages "Type" "in" site.Params.mainSections ) 6 }}
<div class="archive-body">
{{ range $pag.Pages }}
{{ .Render "li" }}
{{ end }}
</div>
{{ partial "pagination" . }}
{{ end }}
"li" is a partial HTML template, which renders a single page for me.
Then I had to specify mainSections in my config.toml. Since my content is located inside content/post directory, here is the configuration.
[params]
mainSections = ["post"]
Since this is a list, you should be able to add more than one section. For example, if your content is spread let's say between content/post and content/articles and so on. I haven't tried this, though.
I know this is an old question, but the easiest way for me to set a particular markdown page as the landing page was simply to create a layouts/index.html to override my theme's, and put this in it:
<script>window.location = "/mainlist"</script>
This way, I can keep all my theme's styling, not worry about editing templates, and just focus on creating the content. As a newcomer to hugo, this worked quite well as a replacement for Pelican's save_as: index.html.
In my Hugo list.html page that is accessed when a user clicks on a category, I'd like the user to be able to see which category they clicked on by displaying it.
I've tried the following code which I think is attempting to get it from the URL:
{{ range .Params.categories }}
{{ . }}
{{ end }}
And my config.toml includes the relevant lines:
[taxonomies]
tag = "tags"
category = "categories"
Presently, nothing is displayed, and no 'a' tags are generated.
The variable .Title is what you are looking for.
When an individual taxonomy term page is being generated, the variable .Title will be set to the current term (that is the actual tag or category).
When the list taxonomy page itself is being generated, it is set to the name of the taxonomy (e.g. tags).
This is different from .Site.Title which is set in the config.toml file.
This is also different from .Title for an individual post which is set from the file's front matter.
So, the following snippet from my website :
<title>{{ .Site.Title }} {{ with .Title }} | {{ . }}{{ end }}</title>
Works equally well for any kind of page since .Title will be automatically set as appropriate for the page type.
Look, Hugo is for writing static (and blog) sites in markdown. GREAT! How do I create the home page (i.e. not the home post)?!
By home page I mean I want to have some markdown file rendered in my theme at the root: http://example.com/, not http://example.com/home (I will change themes if necessary, but I'm currently using hugo-nuo).
Here's how I'm trying to do it:
add my own layouts/index.html (overriding the theme's)
{{ define "main" }}
{{ partial "header.html" . }}
<section class="main">
WHERE I WISH I COULD IMPORT home.md OR SOME SUCH, HECK I'D BE ALRIGHT JUST PUTTING MARKDOWN HERE
</section>
{{ partial "footer.html" . }}
{{ end }}
This incredibly long thread seems to discuss a bunch of issues that've been addressed, but I don't see this answer.
This answer says to use shortcodes. I'm willing to do that, but it looks like shortcodes can only be used from within content (citation needed).
You can add a _index.md into the folder content/ and access it, e.g. via {{ .Content }}.
I am trying to create a responsive image wrap gallery. Each image will have a header. I distribute them using column-count of webkit.
The problem is this: I've specified a container to be "relative". Inside that container, I have an "absolute" header followed by an image. What seems to be happening in some values of column-count is that the header is going to another column and the image in the next. I need them both to be together at all times and I'm surprised why the absolute within relative container is not doing that.
A codepen for reference: http://codepen.io/pliablepixels/full/YwWLzy/
The core image gallery code is:(SO insists I include a code fragment when posting a codepen link, so here goes)
<div style="-webkit-column-count:{{ cols }};-webkit-column-gap:0px;line-height:0px;">
<span ng-repeat="image in images">
<div style="position:relative">
<div class="my_header">Header</div>
<img class="scaled_image" src={{ image.src }} />
</div>
</span>
</div>
Please change the column values and note the header behavior.
How does one solve this? (Note I must use an img tag - can't use background-image)
thanks
Columns
To protect elements from breaking and keep them entirely in a column you can add these properties:
.element {
-webkit-column-break-inside: avoid; /* Chrome, Safari, Opera */
page-break-inside: avoid; /* Firefox */
break-inside: avoid; /* IE 10+ */
}
Your fixed example http://codepen.io/anon/pen/rxMWxa
Header
Such behaviour occurs because you've added line-height:0px to your container div. So you can just return header's line-height value to normal. Fixed that in codepen.
Using line-height sometimes can make headache. Try to use padding like below:
.my_header {
background-color: red;
padding: 2px 4px;
line-height: normal;
}