Comments (5)
I figured out how to strip the HTML links from the description text by using the plainify
filter. But that also turns non-ascii characters into HTML escapes, so I had to run it through htmlUnescape
too. Here's a diff:
diff --git a/layouts/_default/li.html b/layouts/_default/li.html
index 6c65511..f4b5e4a 100644
--- a/layouts/_default/li.html
+++ b/layouts/_default/li.html
@@ -14,10 +14,10 @@
{{- end }}
<article class="card-body">
<h2 class="card-title">{{ .Title }}</h2>
- <p class="card-text">{{ if (isset .Params "description") }}{{ index .Params "description" }}{{ else }}{{ .Summary }}{{ end }}</p>
+ <p class="card-text">{{ if (isset .Params "description") }}{{ index .Params "description" | plainify | htmlUnescape }}{{ else }}{{ .Summary | plainify | htmlUnescape }}{{ end }}</p>
<div class="card-subtext muted-text">
<p>Posted <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "Jan 2, 2006" }}</time></p>
{{ if (isset .Params "categories") }}<p>{{ range .Params.categories }}#{{ . | urlize | title }} {{ end }}</p>{{ end }}
</div>
</article>
-</a>
\ No newline at end of file
+</a>
from aether.
Thanks for opening the issue @snej! What version of Hugo are you running? I am unable to reproduce this issue on 0.63.2. Also, are you doing anything special to put a link in the description? I tried markdown, html a tag, and an html a tag with the raw shortcode. I'm happy to fix this, I just want to understand what is going on on my end.
from aether.
I've got Hugo v0.74.3. It could be the browser — I'm using Safari on Mac OS 10.15.
Nothing special for the description ... I've just got some posts with MarkDown links within the first few sentences of the body.
from aether.
Fixed in c0c3158.
I found out that Hugo only preserves html tags in the summary when using the <!--more-->
summary divider (I'm assuming that's what you were using @snej). The description parameter is not parsed by Hugo so no need for the plainify function there. Let me know if you have any other issues.
from aether.
Aha! I was indeed using <!--more-->
. Thanks for the fix.
from aether.
Related Issues (20)
- cannot use static images for card image HOT 2
- Add support for self hosting external js libraries. HOT 1
- Workaround for rel="alternate" due to google podcasts rule HOT 9
- Category page not found HOT 4
- featured image for a post not working HOT 2
- How do ichange the color of certain text, html tags dont seem to work HOT 5
- I get this error whe i try to use short codes for images
- Add icon on title bar HOT 3
- Featured Image without Page Bundles HOT 3
- Add Dark Mode HOT 2
- bgimg not working HOT 2
- Render fails if no "bgimg" setting HOT 1
- Footer partial template not used anywhere HOT 1
- GitHub/Linkedin links should have alt text HOT 1
- add theme as submodule HOT 1
- Navigation menu broken when JavaScript is disabled HOT 1
- Faceshot not shown HOT 3
- How do you change the home-blob-text and home-blob-title parameters? Maybe add a way in the config.toml file? HOT 2
- Is it possible to change the blob colors? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aether.